[DDC-1079] Behavior of Doctrine 2 is not as defined by EBNF definition for SimpleSelectExpression Created: 25/Mar/11  Updated: 29/Oct/11  Resolved: 27/Mar/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.0.2
Fix Version/s: 2.0.4
Security Level: All

Type: Bug Priority: Minor
Reporter: Daniel Alvarez Arribas Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Queries like

SELECT COUNT(a)
  FROM \a a
 WHERE EXISTS (SELECT 0
      		 FROM \b b
                WHERE b.a = a)

will not work, whereas they should.

Assume that there are potentially millions of b's per a, so this should not be joined, just simply left as-is as a correlated subquery within an exists expression. Actually, a "LIMIT 1" at the end of the subquery would come in handy here, too.

Doctrine 2 will give an error message

[Syntax Error] line 0, col [...]: Error: Expected known function, got '0''

when parsing the DQL statement.

According to the EBNF definition, 0 qualifies as a Literal, which qualifies as an ArithmeticPrimary, which qualifies as an ArithmeticFactor, which qualifies as an ArithmeticTerm, which qualifies as a SimpleArithmeticExpression, which qualifies as a ScalarExpression, which qualifies as a SimpleSelectExpression, which should be perfectly legitimate in that position.

This is yet another annoying case of the Doctrine 2 documentation not matching the behavior of the actual implementation.

Fortunately, it is easy to work around this defect by selecting some field and sacrificing a bit of performance, but then again, it sucks to have to continuously implement workarounds.



 Comments   
Comment by Benjamin Eberlei [ 27/Mar/11 ]

Fixed, didn't work because of a shortcut that was implemented in SimpleSelectExpression. I removed that now and fixed the problem the shortcut was trying to fix at a better location.

Comment by Benjamin Eberlei [ 29/Oct/11 ]

Some more stuff is fixed in regard to this in some lsat ocmmits.

Generated at Sun Apr 20 09:12:36 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.