DDC-1759: Unable to query on column with name 'integer' #2210

Open
opened 2026-01-22 13:44:44 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 3, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user leedavis81:

Currently implementing a poors mans EAV store with Doctrine. I created an entity that has a few data specific columns, and I called them accordingly...

/****
 * @var string $text
 * @Column(name="text", type="text", nullable=true) 
 */
private $text;

/****
 * @var string $string
 * @Column(name="string", type="string", nullable=true) 
 */
private $string;    

/****
 * @var boolean $boolean
 * @Column(name="boolean", type="boolean", nullable=true) 
 */
private $boolean;

/****
 * @var integer $integer
 * @Column(name="integer", type="integer", nullable=true) 
 */    
private $integer;

Quite nicely this was successfully created as a table. However as integer is a reserved keyword with mysql any attempt to insert would fail.

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer, status, created, updated, category_id, merchant_id, image_id) VALUES (1' at line 1

Further to this any attempts at changing this column name using the migration tool would also fail.

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer integer_ INT DEFAULT NULL' at line 1

I can see where I've gone wrong, and realise in hindsight that naming these columns as I've done is asking for trouble, so i'll happily change them. However I thought it might be a good idea that Doctrine handle these a little nicer, perhaps scanning for reserved keywords in the CLI orm:validate-schema tool?

Originally created by @doctrinebot on GitHub (Apr 3, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user leedavis81: Currently implementing a poors mans EAV store with Doctrine. I created an entity that has a few data specific columns, and I called them accordingly... ``` /**** * @var string $text * @Column(name="text", type="text", nullable=true) */ private $text; /**** * @var string $string * @Column(name="string", type="string", nullable=true) */ private $string; /**** * @var boolean $boolean * @Column(name="boolean", type="boolean", nullable=true) */ private $boolean; /**** * @var integer $integer * @Column(name="integer", type="integer", nullable=true) */ private $integer; ``` Quite nicely this was successfully created as a table. However as integer is a reserved keyword with mysql any attempt to insert would fail. SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer, status, created, updated, category_id, merchant_id, image_id) VALUES (1' at line 1 Further to this any attempts at changing this column name using the migration tool would also fail. SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer integer_ INT DEFAULT NULL' at line 1 I can see where I've gone wrong, and realise in hindsight that naming these columns as I've done is asking for trouble, so i'll happily change them. However I thought it might be a good idea that Doctrine handle these a little nicer, perhaps scanning for reserved keywords in the CLI orm:validate-schema tool?
admin added the BugCan't FixInvalid labels 2026-01-22 13:44:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2210