I don't think it's always been like this, as the same queries work under 6.x. An example of this failing is the following:
This fails:
db_query('SELECT nid FROM {node} WHERE type = "article"');
This works:
db_query('SELECT nid FROM {node} WHERE type = \'article\'');
Is this a bug or just undocumented? I would think that double quotes should still be allowed...
Comments
Comment #1
floretan commentedThis came up as an issue for a few tests who were using that synthax. Most of core uses double quotes around queries where string parameters are used:
Comment #2
Susurrus commentedShould that be the case? It is my understanding that pgSQL doesn't support double-quotes for surrounding strings, though that shouldn't be an issue once DB: TNG gets in (assuming it does).
So as of right now it seems like this is still a bug or issue that is undocumented. What is the proper solution to this problem? document or fix?
Comment #3
damien tournoud commentedIn fact the SQL standard define a string literal as
and the quote as
<quote> ::= '(SQL-92 standard pages 80 and 89)
So the double quote is not legal in standard SQL.
The current behavior of
db_query()is thus perfectly correct. Marking as by design.