SQL error with table named 'user' #6412

Closed
opened 2026-01-22 15:32:49 +01:00 by admin · 1 comment
Owner

Originally created by @ashot5706 on GitHub (Feb 24, 2020).

Bug Report

SQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist

Q A
BC Break no
Version v2.10.1

I have table named user, and I getting errors when trying to get something from this table, I looked SQL, and when I'm adding table name in quotes it works, so problem is that in SQL generated by doctrine table name is not in quotes, so this throws error

this is screenshots from VStudio SQL editor
image
image

Originally created by @ashot5706 on GitHub (Feb 24, 2020). ### Bug Report SQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist | Q | A |------------ | ------ | BC Break | no | Version | v2.10.1 I have table named user, and I getting errors when trying to get something from this table, I looked SQL, and when I'm adding table name in quotes it works, so problem is that in SQL generated by doctrine table name is not in quotes, so this throws error this is screenshots from VStudio SQL editor ![image](https://user-images.githubusercontent.com/40325246/75198600-78a61b80-577a-11ea-8f09-e43e7e66273c.png) ![image](https://user-images.githubusercontent.com/40325246/75198619-85c30a80-577a-11ea-9511-6fe0502b5da9.png)
admin closed this issue 2026-01-22 15:32:49 +01:00
Author
Owner

@beberlei commented on GitHub (Feb 25, 2020):

You need to escape the columns like this with the tick symbol ` (I assume you are using the ORM since you opened your issue here):

/**
 * @Table(name="`user`")
 */

Doctrine converts that into quoted columns using the underlying databases identifier quoting syntax.

The other alternative is to use a naming strategy and automatically quote every identifer.

@beberlei commented on GitHub (Feb 25, 2020): You need to escape the columns like this with the tick symbol ` (I assume you are using the ORM since you opened your issue here): ```php /** * @Table(name="`user`") */ ``` Doctrine converts that into quoted columns using the underlying databases identifier quoting syntax. The other alternative is to use a naming strategy and automatically quote every identifer.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6412