Skip to content

Commit 0e63def

Browse files
Jesse Denardotaylorotwell
Jesse Denardo
authored andcommitted
[5.7] Support "geometry" type in Postgres schema grammar (#25323)
* [5.7] Support "geometry" type in Postgres schema grammar * Fix issues that StyleCI identified
1 parent 31ffb9f commit 0e63def

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Illuminate\Database\Schema\Grammars;
44

5-
use RuntimeException;
65
use Illuminate\Support\Fluent;
76
use Illuminate\Database\Schema\Blueprint;
87

@@ -725,11 +724,11 @@ protected function typeMacAddress(Fluent $column)
725724
* Create the column definition for a spatial Geometry type.
726725
*
727726
* @param \Illuminate\Support\Fluent $column
728-
* @throws \RuntimeException
727+
* @return string
729728
*/
730729
protected function typeGeometry(Fluent $column)
731730
{
732-
throw new RuntimeException('The database driver in use does not support the Geometry spatial column type.');
731+
return $this->formatPostGisType('geometry');
733732
}
734733

735734
/**

tests/Database/DatabasePostgresSchemaGrammarTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,15 +702,14 @@ public function testCompileForeign()
702702
$this->assertEquals('alter table "users" add constraint "users_parent_id_foreign" foreign key ("parent_id") references "parents" ("id") on delete cascade deferrable initially deferred', $statements[0]);
703703
}
704704

705-
/**
706-
* @expectedException \RuntimeException
707-
* @expectedExceptionMessage The database driver in use does not support the Geometry spatial column type.
708-
*/
709705
public function testAddingGeometry()
710706
{
711707
$blueprint = new Blueprint('geo');
712708
$blueprint->geometry('coordinates');
713-
$blueprint->toSql($this->getConnection(), $this->getGrammar());
709+
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
710+
711+
$this->assertCount(1, $statements);
712+
$this->assertEquals('alter table "geo" add column "coordinates" geography(geometry, 4326) not null', $statements[0]);
714713
}
715714

716715
public function testAddingPoint()

0 commit comments

Comments
 (0)