Working with a "group" word in entity #6480

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

Originally created by @tasselchof on GitHub (Jun 3, 2020).

Bug Report

Q A
BC Break yes/no
Version 2.8

Summary

Insert with the word "group" not working well on PostgreSQL.

2020-06-03T11:10:02+00:00 WARN (4): An exception occurred while executing 'INSERT INTO storage_picking_task (priority, group, id, state, created, updated, queue_id, executive_id, item, place_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["1312", null, 909944, "new", "2020-06-03 11:10:02+0000", "2020-06-03 11:10:02+0000", 50, null, 1833099, 20223]:

SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "group"
LINE 1: INSERT INTO storage_picking_task (priority, group, id, state

Originally created by @tasselchof on GitHub (Jun 3, 2020). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes/no | Version | 2.8 #### Summary Insert with the word "group" not working well on PostgreSQL. 2020-06-03T11:10:02+00:00 WARN (4): An exception occurred while executing 'INSERT INTO storage_picking_task (priority, group, id, state, created, updated, queue_id, executive_id, item, place_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["1312", null, 909944, "new", "2020-06-03 11:10:02+0000", "2020-06-03 11:10:02+0000", 50, null, 1833099, 20223]: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "group" LINE 1: INSERT INTO storage_picking_task (priority, group, id, state
admin closed this issue 2026-01-22 15:33:52 +01:00
Author
Owner

@Xesau commented on GitHub (Jul 8, 2020):

In PostgreSQL, you can wrap a field name in double quotes (") to prevent it from being interpreted as a keyword, such as with group.1 (The equivalent in MySQL is using backticks (`))

In your entity configuration, you can specify that Doctrine should wrap the column name in double quotes. For example, using Annotations, you can use @ORM\Column(name="\"group\"") to achieve this. Notice that you have to escape the double quote characters, because in Annotations you can only specify string literals in double quotes.

[1] https://stackoverflow.com/questions/7651417/escaping-keyword-like-column-names-in-postgres

@Xesau commented on GitHub (Jul 8, 2020): In PostgreSQL, you can wrap a field name in double quotes (`"`) to prevent it from being interpreted as a keyword, such as with `group`.<sup>1</sup> (The equivalent in MySQL is using backticks (<code>`</code>)) In your entity configuration, you can specify that Doctrine should wrap the column name in double quotes. For example, using Annotations, you can use `@ORM\Column(name="\"group\"")` to achieve this. Notice that you have to escape the double quote characters, because in Annotations you can only specify string literals in double quotes. [1] https://stackoverflow.com/questions/7651417/escaping-keyword-like-column-names-in-postgres
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6480