Skip to content
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

DDC-863: DQL: EBNF for IN expressions is incorrect #5385

Closed
doctrinebot opened this issue Nov 6, 2010 · 2 comments
Closed

DDC-863: DQL: EBNF for IN expressions is incorrect #5385

doctrinebot opened this issue Nov 6, 2010 · 2 comments
Labels

Comments

@doctrinebot
Copy link

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

@doctrinebot
Copy link
Author

Comment created by dalvarez:

I close this bug, which is still unresolved, combining Bugs 857, 863 and 864 into Bug 866.

@doctrinebot
Copy link
Author

Issue was closed with resolution "Duplicate"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant