mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Working with a "group" word in entity #6480
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tasselchof on GitHub (Jun 3, 2020).
Bug Report
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
@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 withgroup.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