doctrine / dbal

Doctrine Database Abstraction Layer
https://www.doctrine-project.org/projects/dbal.html
MIT License
9.49k stars 1.34k forks source link

DBAL-1112: sqlite - Insert statement with keyword as column name raises sql-error #1052

Closed doctrinebot closed 9 years ago

doctrinebot commented 9 years ago

Jira issue originally created by user floriansemm:

We are using a sqlite db in our unit tests. During fixtures-load a error occurs:

{quote} [Doctrine\DBAL\Exception\SyntaxErrorException]
An exception occurred while executing 'INSERT INTO state (name, type, group) VALUES (?, ?, ?)':
SQLSTATE[HY000]: General error: 1 near "group": syntax error {quote}

We are using for all queries, in our symfony2 application, the doctrine-orm (v2.4.7). So this query is auto-generated.

The reason for this error is a wrong syntax of the insert statement:

INSERT INTO state (name, type, group) VALUES ('a*name', 'a_type', 'a*group');

The group column is a sqlite-keyword and must surround with " or '. A query like this

INSERT INTO state (name, type, 'group') VALUES ('a*name', 'a_type', 'a*group');

works fine.

doctrinebot commented 9 years ago

Comment created by floriansemm:

I found the resolution in the documentation

doctrinebot commented 9 years ago

Issue was closed with resolution "Won't Fix"

errogaht commented 7 years ago

issue not closed, I have the same bug! SQLite-keyword and must surround with " or '. please fix it!

errogaht commented 7 years ago

I very glad for floriansemm, but if someone else needs to fix it too, here is link http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.