mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Select New operator doesn't support NULL #6808
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 @carnage on GitHub (Aug 14, 2021).
Bug Report
Summary
Results in the error:
Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 175: Error: Unexpected 'null'Documentation says you can use any scalar expression in the fields of the new statement
Current behavior
True, false, ints and strings are supported, null should be included for completeness
How to reproduce
Here's a test case
@SenseException commented on GitHub (Aug 14, 2021):
PHP's
is_scalardoesn't seenullas scalar too (https://3v4l.org/SaZGu) but I actually would like to see null to be supported. I would consider this a feature request.@carnage commented on GitHub (Aug 15, 2021):
Looked into this and its going to be a nightmare to fix, parser dosent seem to accept null as a literal /anywhere/
So the first thing to decide is: will there be any side effects from adding a case for null to the literal class; how should they be handled; would it be better to add a specific Null AST node which can then be restricted to only being used in specific context's such as New expressions?
@greg0ire commented on GitHub (Aug 15, 2021):
I also looked into it, and saw that occurrences of
NULLwere supported as part of a comparison:d636d79686/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php (L24)That makes sense since
NULLis special in SQL. Here, we are talking about PHP'snullthough, since we are constructing a PHP object.IMO a specific AST node would be better. I suggest
NewObjectNullArgas a name.