-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QueryBuilder Update Query doesn't work if no alias is used. #9733
Comments
Can you tell us in which version this piece of code worked? |
i'm not sure if that had worked or not, i would need to experiment. But from the parameters of the QueryBuilder the alias isn't required. |
You can omit both parameters, but I don't think that it is intended that you specify the first parameter only. Since that would produce an invalid DQL anyway, I think we can throw an exception in that case. Do you want to open a PR? |
Oh, and this affects the |
i checked the code, if you omit both parameters, than it does nothing. (for what ever reason that is possible) the only possible way would be if the alias would be part of the |
Correct, you would need to add the target class and alias by calling
You are correct. That would mean we cannot just throw an exception, but we should deprecate omitting the alias and turn the deprecation into an exception in 3.0. |
i might not have enough understanding of Doctrine to write the possible PR myself. like for example first question: should it still be possible to call for the second, i would just add a trigger warning for now that says that omitting the alias is deprecated. |
No worries, I can assist you during code review.
Yes.
Yes, please use this method for triggering the deprecation: Also, please document this change in UPGRADE.md. Please target the 2.13.x branch. |
Fixed via b931a59 |
Bug Report
Summary
If no alias is used, the Query Builder seems to have problems to build the query, or the lexer that is checking the query thinks it is invalid when it is not.
Current behavior
Currently it is crashing with an Exception, see below.
How to reproduce
having this QueryBuilder:
makes this Query:
UPDATE App\Entity\User\User SET klassenstufe = klassenstufe+1 WHERE id IN(188)
and causes this crash:
But having this QueryBuilder:
makes this Query:
UPDATE App\Entity\User\User u SET u.klassenstufe = u.klassenstufe+1 WHERE u.id IN(188)
Causing it to work.
IF the alias is needed, then it shouldn't be an optional parameter for the update function.
Or it should be better documented.
i don't know if that is a BC or not, but i think it was working before.
Expected behavior
The Query to be executed.
The text was updated successfully, but these errors were encountered: