DQL: Allow double quotes to encapsulate strings or state more clearly that only single quotes are allowed
I have run crazy the last days because concatenation of a field with a scalar string failed with a syntax error. I am used to encapsulating strings in PHP using single quotes, hence I used the following code to create my query
// ...
->select('CONCAT(customer.firstname, " ", customer.lastname) AS full_name')
// ...
After a lot of trial and error I figured out, that only single quotes are allowed to encapsulate strings in DQL, so I could solve my issue this way
// ...
->select('CONCAT(customer.firstname, \' \', customer.lastname) AS full_name')
// ...
I have just read through the whole documentation about DQL (https://github.com/doctrine/doctrine2/blob/master/docs/en/reference/dql-doctrine-query-language.rst) and finally found the part describing "terminals" in the EBNF section. The only hint about how to correctly encapsulate strings is that the given examples only use single quotes, but it is not clearly stated that double quotes are not allowed.
I wonder why double quotes are not allowed, are they used for some other purpose? Or is this a bug? If it is not a bug, I would highly recommend to state this behavior more clearly in the documentation, because standard SQL is agnostic of the type of quotes used to encapsulate a string and therefore DQL's behavior is a little unexpected. If it already is stated somewhere, I would appreciate if someone could post a link to that page.
The lexer only allows single quotes for now: https://github.com/doctrine/doctrine2/blob/a4d84e0cd8cc4ea1b99f4fd7d1d560f3fbe27c30/lib/Doctrine/ORM/Query/Lexer.php#L166-L169
Not aware of the implications of supporting also double quotes /cc @guilhermeblanco
Please allow double quotes - this is a very simple fix