GNOME Bugzilla – Bug 663608
Incorrect escaping of " in SQL IDs
Last modified: 2013-11-06 09:57:01 UTC
Created attachment 200969 [details] test_libgda_postgresql_id_escaping.c This test case shows that gda_connection_quote_sql_identifier() incorrectly escapes " as \" instead of "" as specified here: http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html "To include a double quote, write two double quotes." The SQL query is then rejected by PostgreSQL like so: ** WARNING **: gda_connection_statement_execute() failed: syntax error at or near "inmiddle" LINE 1: CREATE TABLE "tablenamewith\"inmiddle" (somefield numeric PR...
See correction in commit http://git.gnome.org/browse/libgda/commit/?id=ad1976252faaae4386c9429d065c48cd456a1e57 Can you check it's Ok? Vivien
Thanks, yes, that fixes my Glom test case for PostgreSQL. It's apparently also wrong for SQLite. I'm seeing this similar error: ConnectionError: near "quote": syntax error for CREATE TABLE "sometablewith\"quote" ("sometablewith\"quote_id" numeric NOT NULL PRIMARY KEY, "description" varchar, "comments" varchar, "glom_lock" varchar) But I have not investigated what syntax SQLite officially requires.
(In reply to comment #2) > But I have not investigated what syntax SQLite officially requires. This suggests that it should be the same as in PostgreSQL: http://www.sqlite.org/lang_expr.html "A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal. C-style escapes using the backslash character are not supported"
This seems to be fixed now.