You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But unlike Bug DDC-857, including even a single relationship in the path expression matched against the IN values is not allowed here. So it could very well be that a SingleValuedAssociationPathExpression can not actually used in IN expressions at all, and the DQL for IN expressions actually supported by the implementation needs to be described in a separate EBNF definition, like:
Jira issue originally created by user dalvarez:
Any DQL query of the following form:
SELECT a FROM \SomeNamespace\SomeClass a
WHERE a.someRelationship.someField IN (1)
will not work, giving an error message like the one shown below:
exception 'Doctrine\ORM\Query\QueryException' with message '[Syntax Error] line 0, col 112: Error: Expected Doctrine\ORM\Query\Lexer::T_IN, got '.'' in /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/QueryException.php:42 Stack trace: #0 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(345): Doctrine\ORM\Query\QueryException::syntaxError('line 0, col 112...') #1 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(240): Doctrine\ORM\Query\Parser->syntaxError('Doctrine\ORM\Qu...') #2 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(2433): Doctrine\ORM\Query\Parser->match(123) #3 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1936): Doctrine\ORM\Query\Parser->InExpression() #4 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1870): Doctrine\ORM\Query\Parser->SimpleConditionalExpression() #5 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1829): Doctrine\ORM\Query\Parser->ConditionalPrimary() #6 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1799): Doctrine\ORM\Query\Parser->ConditionalFactor() #7 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1775): Doctrine\ORM\Query\Parser->ConditionalTerm() #8 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1163): Doctrine\ORM\Query\Parser->ConditionalExpression() #9 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(718): Doctrine\ORM\Query\Parser->WhereClause() #10 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(687): Doctrine\ORM\Query\Parser->SelectStatement() #11 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(202): Doctrine\ORM\Query\Parser->QueryLanguage() #12 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(273): Doctrine\ORM\Query\Parser->getAST() #13 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query.php(203): Doctrine\ORM\Query\Parser->parse() #14 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query.php(223): Doctrine\ORM\Query->_parse() #15 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/AbstractQuery.php(528): Doctrine\ORM\Query->_doExecute() #16 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/AbstractQuery.php(366): Doctrine\ORM\AbstractQuery->execute(Array, 1)
By contrast, DQL queries of the form
SELECT a FROM \SomeNamespace\SomeClass a
WHERE a.someField IN (1)
will work.
This is contradicted by the EBNF definition of DQL, which includes the following definitions:
InExpression ::= StateFieldPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")"
StateFieldPathExpression ::= IdentificationVariable "." StateField | SingleValuedAssociationPathExpression "." StateField
SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField
I consider this a (documentation) bug, because the documentation says Doctrine 2 can do something which it actually can not do.
It boils down to the SingleValuedAssociationPathExpression not being fully supported here, which is very similiar to bug DDC-857 (http://www.doctrine-project.org/jira/browse/[DDC-857](http://www.doctrine-project.org/jira/browse/DDC-857)), which refers to the SingleValuedAssociationPathExpression not being fully supported (the way it is documented) in ArithmeticExpressions.
But unlike Bug DDC-857, including even a single relationship in the path expression matched against the IN values is not allowed here. So it could very well be that a SingleValuedAssociationPathExpression can not actually used in IN expressions at all, and the DQL for IN expressions actually supported by the implementation needs to be described in a separate EBNF definition, like:
InExpression ::= InExpressionStateFieldPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")"
InExpressionStateFieldPathExpression ::= IdentificationVariable "." StateField
The text was updated successfully, but these errors were encountered: