Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-1071

CASE expressions do not work as documented in EBNF


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.2
    • Component/s: Documentation
    • Security Level: All
    • Labels:


      The EBNF definition of DQL on the website (http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html) defines the SELECT expression as follows:

      SelectExpression ::= IdentificationVariable | PartialObjectExpression | (AggregateExpression | "(" Subselect ")" | FunctionDeclaration | ScalarExpression) [["AS"] AliasResultVariable]

      A ScalarExpression, in turn, is defined as follows:

      ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary | StateFieldPathExpression BooleanPrimary | CaseExpression | EntityTypeExpression

      There is already a missing ''|" between "StateFieldPathExpression" and "BooleanPrimary" here.

      But ignoring that detail, this definition states that case expressions can show up anywhere in the list of values to be selected in a query, which, of course, would come in handy.

      Contrary to this definition, queries like this one will not work:

      SELECT someEntity.a, CASE someEntity.b WHEN 1 THEN 'A' ELSE 'B' END FROM \someEntity;

      Whereas queries like this one will:

      SELECT CASE someEntity.b WHEN 1 THEN 'A' ELSE 'B' END FROM \someEntity;

      Both queries should be legitimate, according to the EBNF definition.

      In addition, CASE expressions are not allowed in subselects either, although the EBNF definition of the SimpleSelectExpression states that they should be.

        Issue Links



            • Assignee:
              guilhermeblanco Guilherme Blanco
              dalvarez Daniel Alvarez Arribas
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: