mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Alias can't be used in functions, causes SqlWalker to crash #6318
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 @romaricdrigon on GitHub (Oct 1, 2019).
Originally assigned to: @Ocramius on GitHub.
Bug Report
Summary
Hello,
It is not possible to use an alias inside a DQL function, in a WHERE or HAVINg clause. SqlWalker crashes.
I will add a failing test scenario in a PR in a few minutes, I'm creating this issue to get a ticket number first.
Current behavior
Failure.
Example with a
mainAccountEmailalias:How to reproduce
This query will fail:
SELECT u.name AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(foo) = '3'Expected behavior
It should not crash, and generates a correct WHERE clause.
For the previous example:
SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE LOWER(name_0) = '3'@Ocramius commented on GitHub (Oct 1, 2019):
Closing here: this is correct behavior:
WHERE LOWER(u.name) = '3'is correct/expected usage in DQL.@romaricdrigon commented on GitHub (Oct 1, 2019):
@Ocramius I'm not sure to understand:
It doesn't work at the moment. So incorrect/unexpected?
@Ocramius commented on GitHub (Oct 1, 2019):
Hmm, that doesn't work either? What's the exception in that case?
@romaricdrigon commented on GitHub (Oct 1, 2019):
You can check https://github.com/doctrine/orm/pull/7847 for more details.
@romaricdrigon commented on GitHub (Oct 4, 2019):
@Ocramius I believe this issue was dismissed too quickly, and PR #7847 too, since there are pending comments. Maybe you should reopen them?