-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of table and column names using reserved words
- Loading branch information
Showing
12 changed files
with
167 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Jsor\Doctrine\PostGIS; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* Entity with reserved words as table and column names. | ||
* | ||
* @ORM\Entity | ||
* @ORM\Table( | ||
* name="`user`" | ||
* ) | ||
*/ | ||
class ReservedWordsEntity | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
* @ORM\GeneratedValue | ||
*/ | ||
private $id; | ||
|
||
|
||
/** | ||
* @ORM\Column(type="geometry", name="`user`") | ||
*/ | ||
private $user; | ||
|
||
/** | ||
* @ORM\Column(type="geography", name="`primary`") | ||
*/ | ||
private $primary; | ||
|
||
public function __construct(array $points) | ||
{ | ||
foreach ($points as $key => $val) { | ||
$this->$key = $val; | ||
} | ||
} | ||
|
||
public function getUser() | ||
{ | ||
return $this->user; | ||
} | ||
|
||
public function getPrimary() | ||
{ | ||
return $this->primary; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE SEQUENCE user_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
CREATE TABLE "user" (id INT NOT NULL, "primary" geography(GEOMETRY, 4326) NOT NULL, PRIMARY KEY(id)); | ||
|
||
SELECT AddGeometryColumn('user', 'user', -1, 'GEOMETRY', 2); | ||
ALTER TABLE "user" ALTER "user" SET NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP SEQUENCE IF EXISTS user_id_seq CASCADE; | ||
SELECT DropGeometryTable('user'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE SEQUENCE user_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
CREATE TABLE user (id INT NOT NULL, "user" geometry(GEOMETRY, 0) NOT NULL, "primary" geography(GEOMETRY, 4326) NOT NULL, PRIMARY KEY(id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP SEQUENCE IF EXISTS user_id_seq CASCADE; | ||
DROP TABLE IF EXISTS "user"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE SEQUENCE user_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
CREATE TABLE "user" (id INT NOT NULL, "user" geometry(GEOMETRY, 0) NOT NULL, "primary" geography(GEOMETRY, 4326) NOT NULL, PRIMARY KEY(id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP SEQUENCE IF EXISTS user_id_seq CASCADE; | ||
DROP TABLE IF EXISTS "user"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE SEQUENCE user_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
CREATE TABLE "user" (id INT NOT NULL, "user" geometry(GEOMETRY, 0) NOT NULL, "primary" geography(GEOMETRY, 4326) NOT NULL, PRIMARY KEY(id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP SEQUENCE IF EXISTS user_id_seq CASCADE; | ||
DROP TABLE IF EXISTS "user"; |