Skip to content

[5.7] Support "geometry" type in Postgres schema grammar #25323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\Database\Schema\Grammars;

use RuntimeException;
use Illuminate\Support\Fluent;
use Illuminate\Database\Schema\Blueprint;

Expand Down Expand Up @@ -725,11 +724,11 @@ protected function typeMacAddress(Fluent $column)
* Create the column definition for a spatial Geometry type.
*
* @param \Illuminate\Support\Fluent $column
* @throws \RuntimeException
* @return string
*/
protected function typeGeometry(Fluent $column)
{
throw new RuntimeException('The database driver in use does not support the Geometry spatial column type.');
return $this->formatPostGisType('geometry');
}

/**
Expand Down
9 changes: 4 additions & 5 deletions tests/Database/DatabasePostgresSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,14 @@ public function testCompileForeign()
$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]);
}

/**
* @expectedException \RuntimeException
* @expectedExceptionMessage The database driver in use does not support the Geometry spatial column type.
*/
public function testAddingGeometry()
{
$blueprint = new Blueprint('geo');
$blueprint->geometry('coordinates');
$blueprint->toSql($this->getConnection(), $this->getGrammar());
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table "geo" add column "coordinates" geography(geometry, 4326) not null', $statements[0]);
}

public function testAddingPoint()
Expand Down