mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Parsing CASE expressions throws an exception when it contains NULL as a result value #5115
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 @mkruk-u2 on GitHub (Apr 28, 2016).
Originally assigned to: @mkruk-u2 on GitHub.
Case expressions (
GeneralCaseExpression,SimpleCaseExpression) doesn't allow to use NULL value inCASESQL statement:These expressions expect
ScalarExpression, which do not handle NULL values: https://github.com/doctrine/doctrine2/blob/v2.5.4/lib/Doctrine/ORM/Query/Parser.php#L1936.Is this expected and correct behaviour?
It seems that this syntax is valid SQL syntax (at least in MySQL 5.5, MySQL 5.6, PostgreSQL 9.3, SQLite).
@buffcode commented on GitHub (Oct 11, 2017):
You can try working around this issue by using a parameter and binding it to
NULL, though it not working in all cases.@mkruk-u2 commented on GitHub (Oct 12, 2017):
@buffcode True. But as you noticed yourself - it's just a workaround.
This can also be "hacked" by using
NULLIF(which is supported):But the question was more about why
NULLis not supported in the first place?It seems that extending this
casestatement withcase ($lookahead === Lexer::T_NULL):(and probably adding few constants here and there) should do the job. But maybe there is a reason why it's not done already.@lcobucci commented on GitHub (Nov 26, 2017):
@mkruk-u2 could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing.
You can find examples on
388afb46d0/tests/Doctrine/Tests/ORM/Functional/Ticket@mkruk-u2 commented on GitHub (Dec 29, 2017):
@lcobucci I've added a failing test case (https://github.com/doctrine/doctrine2/pull/6944)
@Flyrell commented on GitHub (Aug 8, 2018):
Hey guys, what's the status on this one?
@Ocramius commented on GitHub (Aug 8, 2018):
@Flyrell give #6944 a stab