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
SELECT a FROM \SomeNamespace\SomeClass a
WHERE a.someField IN (SELECT b.someRelationship.someField FROM \SomeNamespace\SomeOtherClass b
WHERE b.someOtherField = :whatever)
SELECT a FROM \SomeNamespace\SomeClass a
WHERE a.someField IN (SELECT b.someField FROM \SomeNamespace\SomeOtherClass b
WHERE b.someOtherField = :whatever)
I think all the EBNF relating to path expressions needs some serious reworking. It seems that the SingleValuedAssociationPathExpression never works as described. Currently it is not elegantly possible to work with DQL queries that involve various related entities without performing manual joins.
The ideal fix would probably be to implement support for the SingleValuedAssociationPathExpression the way it is documented. It really makes sense and should not be too difficult to implement, but would be a real win in terms of usability.
The text was updated successfully, but these errors were encountered:
It is a documentation issue. The BNF has not yet been updated. Support for "deep" path expressions, which was only a (small) convenience for more explicit joins, are no longer supported due to too many complications in the implementation.
Please do not open any more tickets that are about the same issue. A single ticket that says that the EBNF in the documentation needs to be updated would be ideal. Thank you.
You were. I didn't mean to critize the tickets :) The way you wrote them is exemplary. Please keep this style for any new tickets, it really helps to quickly grasp the issue.
Jira issue originally created by user dalvarez:
DQL queries of the following form will not work:
SELECT a FROM \SomeNamespace\SomeClass a
WHERE a.someField IN (SELECT b.someRelationship.someField FROM \SomeNamespace\SomeOtherClass b
WHERE b.someOtherField = :whatever)
failing with an error like
exception 'Doctrine\ORM\Query\QueryException' with message '[Syntax Error] line 0, col 137: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, 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 137...') #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(1142): Doctrine\ORM\Query\Parser->match(120) #3 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1229): Doctrine\ORM\Query\Parser->SubselectFromClause() #4 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(2077): Doctrine\ORM\Query\Parser->Subselect() #5 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(2407): Doctrine\ORM\Query\Parser->ArithmeticExpression() #6 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1947): Doctrine\ORM\Query\Parser->ComparisonExpression() #7 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1863): Doctrine\ORM\Query\Parser->SimpleConditionalExpression() #8 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1829): Doctrine\ORM\Query\Parser->ConditionalPrimary() #9 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1799): Doctrine\ORM\Query\Parser->ConditionalFactor() #10 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1775): Doctrine\ORM\Query\Parser->ConditionalTerm() #11 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(1163): Doctrine\ORM\Query\Parser->ConditionalExpression() #12 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(718): Doctrine\ORM\Query\Parser->WhereClause() #13 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(687): Doctrine\ORM\Query\Parser->SelectStatement() #14 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(202): Doctrine\ORM\Query\Parser->QueryLanguage() #15 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/Parser.php(273): Doctrine\ORM\Query\Parser->getAST() #16 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query.php(203): Doctrine\ORM\Query\Parser->parse() #17 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query.php(223): Doctrine\ORM\Query->_parse() #18 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/AbstractQuery.php(528): Doctrine\ORM\Query->_doExecute() #19 /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/AbstractQuery.php(366): Doctrine\ORM\AbstractQuery->execute(Array, 1)
Whereas queries of the form:
SELECT a FROM \SomeNamespace\SomeClass a
WHERE a.someField IN (SELECT b.someField FROM \SomeNamespace\SomeOtherClass b
WHERE b.someOtherField = :whatever)
will work.
The following EBNF definitions told me to do it:
Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression
SimpleSelectExpression ::= ScalarExpression | IdentificationVariable |
(AggregateExpression [["AS"] AliasResultVariable])
ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary | StateFieldPathExpression
BooleanPrimary | CaseExpression | EntityTypeExpression
StateFieldPathExpression ::= IdentificationVariable "." StateField | SingleValuedAssociationPathExpression "." StateField
SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField
Of course, the query shown above is impractical, because ideally it could all be written as a single path expression, but I was trying to work around Bug http://www.doctrine-project.org/jira/browse/[DDC-857](http://www.doctrine-project.org/jira/browse/DDC-857).
I think all the EBNF relating to path expressions needs some serious reworking. It seems that the SingleValuedAssociationPathExpression never works as described. Currently it is not elegantly possible to work with DQL queries that involve various related entities without performing manual joins.
See Bugs http://www.doctrine-project.org/jira/browse/[DDC-857](http://www.doctrine-project.org/jira/browse/DDC-857) and http://www.doctrine-project.org/jira/browse/[DDC-863](http://www.doctrine-project.org/jira/browse/DDC-863)
The ideal fix would probably be to implement support for the SingleValuedAssociationPathExpression the way it is documented. It really makes sense and should not be too difficult to implement, but would be a real win in terms of usability.
The text was updated successfully, but these errors were encountered: