Jira issue originally created by user felicitus:
I have an entity "User" in D2-ORM which works fine on MySQL. However, when I tried to create the schema on PostgreSQL 9.0, it failed with the following error:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE: Syntax error: 7 ERROR: syntax error at or near "User"
LINE 1: CREATE TABLE User (id INT NOT NULL, username VARCHAR(50) NOT...
^' in /usr/share/php/Doctrine/DBAL/Connection.php:577
The generated statement caused this was: CREATE TABLE User (id INT NOT NULL, username VARCHAR(50) NOT NULL, password VARCHAR(32) NOT NULL, admin BOOLEAN NOT NULL, PRIMARY KEY(id))
"User" needs to be quoted in order to work (I tested against PostgreSQL 9.0).
Comment created by @beberlei:
Doctrine does not do auto-escaping.
Please read the docs on quoting reserved words: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#quoting-reserved-words
Issue was closed with resolution "Invalid"
Comment created by felicitus:
It's not that easy.
I can, of course, escape the table in the entity, e.g.
/*** @Entity @Table(name="User") **/
However, when using the SchemaTool, it will fail on the 2nd run because it tries to:
DROP TABLE User
That fails, of course.
how are things so far with this issue ?
@samusenkoiv this issue is old and should be fixed already considering that USER is registered as reserved keyword in Doctrine and the platform explicitly quoting table names in getCreateTableSQL(). What issue are you having?
I've already found the way to define user table:
Thanks for your attention.
@samusenkoiv you can do that by explicit quoting for sure but DBAL supports auto quoting reserved keywords. Can you please test if it works without quotes? If not, which statement(s) are failing? Because if this still is a bug, it needs our attention. Also please tell which DBAL version you are using. Thanks for your help!
You're right, I tried it with:
And everything worked well, I probably made a mistake.
Thank for a fast feedback.
@samusenkoiv you're welcome. Thanks for investigating. Closing again as fixed, but as I do not know when it was fixes, no milestone attached.