mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DQL Syntax Errors when upgrading to 2.6.0 #5829
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 @ohartl on GitHub (Jan 3, 2018).
Originally assigned to: @Ocramius on GitHub.
This DQL and others with the same problem (I anonymized it here) used to work with 2.5.x:
Now with 2.6.0 I get this error.
Not sure if its my fault not using the correct syntax, this worked in the previous version of doctrine/orm, or its a BC break maybe?!
@Ocramius commented on GitHub (Jan 3, 2018):
Uhh... I didn't even know multiple
WHEREworked - that is most likely a bug in your code, and we simply made the DQL align to the [EBNF definition](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#ebnf@Ocramius commented on GitHub (Jan 3, 2018):
Also, arbitrary join conditions require a
WITHclause...@ohartl commented on GitHub (Jan 3, 2018):
Well, multiple
WHEREused to work in 2.5.x, and my coworker hadReplacing the
WHEREfor joins withWITHfixed the problem. Thanks :)Btw. shouldn't the documentation use
WITHinstead ofWHEREin the (at least first two) examples?@Ocramius commented on GitHub (Jan 3, 2018):
@ohartl they weren't really supposed to work :S
As for the documentation you linked, those are not arbitrary joins, but joins over associations.
@ohartl commented on GitHub (Jan 3, 2018):
Ok, thanks
@amici commented on GitHub (May 29, 2019):
I'm somewhat late to v2.6.*, but I also stumbled on a similar issue. Here is my case, if there are others with similar misfortune.
In 2.5.14, it was possibly to join two unrelated entities without the WITH keyword, like:
Most likely, this would be done by error, and the full cross JOIN would be a result, but still the query would work. With enough results in the WHERE part - maybe even as it should.
Note that this query could also be done if the 2 entities are actually properly related (like many-to-one), and possibly the dev presumed that the JOIN will just automagically do its job.
In v2.5, the query generated from the above would be something like:
So, the ORM would put all the WHERE conditions INTO the ON part and make the SQL work.
In v2.6.3 that query simply fails. As far as I saw, the ORM tries to build something like this:
So, the ORM does not try anymore to be smart and strictly does what it was told: it puts the WHERE conditions to WHERE in the SQL and also completely skips adding the ON part in the join.
But, it eventually complains, with a "Incorrect syntax near the keyword 'WHERE'" error, because it actually expects the JOIN to have the ON part.
Anyway... I had to clear this out for me (and maybe for someone else), because it was an unexpected BC break, even if it was really a case of stop-tolerating-wrong-code BC break.