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-857: Wrong DQL documentation - actual support for a SingleValuedAssociationPathExpression does not comply to its EBNF definition #5378

Closed
doctrinebot opened this issue Nov 3, 2010 · 6 comments
Labels

Comments

@doctrinebot
Copy link

Jira issue originally created by user dalvarez:

I have a DQL query that is basically

'SELECT x
FROM \PathToTheEntityClass\SomeEntityClass x
WHERE x.someSingleValuedAssociation.anotherSingleValuedAssociation.id = :someID'

This query results in an exception being thrown, like the one shown below.

exception 'Doctrine\ORM\Query\QueryException' with message '[Syntax Error] line 0, col 112: Error: Expected =, <, <=, <>, >, >=, !=, 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(2621): Doctrine\ORM\Query\Parser->syntaxError('=, <, <=, <>, >...') #2 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(2408): Doctrine\ORM\Query\Parser->ComparisonOperator() #3 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1947): Doctrine\ORM\Query\Parser->ComparisonExpression() #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) #17 /var/www/invoiceCreator/src/persistentData/DB.php(81): Doctrine\ORM\AbstractQuery->getResult() #18

I also tried to directly refer to the association instead of its ID field, like this:

'SELECT x
FROM \PathToTheEntityClass\SomeEntityClass x
WHERE x.someSingleValuedAssociation.anotherSingleValuedAssociation = :someObjectOfTheCorrespondingType'

This results in the same error.

I read the EBNF definition at http://www.doctrine-project.org/projects/orm/2.0/docs/reference/dql-doctrine-query-language/en#dql-doctrine-query-language, and if I am not missing something here, both queries should be legitimate. I think there is the problem with traversing more than one association in a path expression. The corresponding definition for the first expression within the WHERE clause is a SingleValuedAssociationPathExpression, defined as:

SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField

So a SingleValuedAssociationPathExpression is defined to be an identification variable, followed by a dot, followed by a theoretically infinite series of association fields (i. e. relationship attributes), separated from each other by a dot.

I should be able to use this expression in a WhereClause, because a ComparisonExpression can contain a ConditionalExpression, which can contain an ArithmeticExpression, which can contain a SingleValuedPathExpression, which can be either a StateFieldPathExpr, or a SingleValuedAssociationPathExpression.

In effect this means that the user currently needs to do all but the most trivial joins manually, right?

@doctrinebot
Copy link
Author

Comment created by @beberlei:

We removed support for this kind of queries since they considerably raised the complexity and runtime in the DQL parser. Use the Explicit join syntax please, the generated SQL would look the same anyways.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Oh and maybe the EBNF needs updating in this regards.

@doctrinebot
Copy link
Author

Comment created by dalvarez:

I reopen this as a documentation issue.

The Website still documents DQL with:

SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField

which obviously will not work.

@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.

1 similar comment
@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