Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1071

CASE expressions do not work as documented in EBNF

    Details

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

      Description

      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

          Activity

          Daniel Alvarez Arribas created issue -
          Daniel Alvarez Arribas made changes -
          Field Original Value New Value
          Description
          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 ''|" here 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 EBDF definition.

          In addition, CASE expressions in subselects will not work,either, though the EBNF definition of the SimpleSelectExpr states that they should.
          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 EBDF definition.

          In addition, CASE expressions in subselects will not work,either, though the EBNF definition of the SimpleSelectExpr states that they should.
          Daniel Alvarez Arribas made changes -
          Description 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 EBDF definition.

          In addition, CASE expressions in subselects will not work,either, though the EBNF definition of the SimpleSelectExpr states that they should.
          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 EBDF definition.
          Daniel Alvarez Arribas made changes -
          Description 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 EBDF definition.
          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 EBDF definition.


          In addition, CASE expressions are not allowed in subselects either, although the EBNF definition of the SimpleSelectExpression states that they should be.
          Benjamin Eberlei made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Duplicate [ 3 ]
          Benjamin Eberlei made changes -
          Link This issue depends on DDC-3 [ DDC-3 ]
          Daniel Alvarez Arribas made changes -
          Resolution Duplicate [ 3 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Daniel Alvarez Arribas made changes -
          Component/s Documentation [ 10013 ]
          Component/s DQL [ 10014 ]
          Daniel Alvarez Arribas made changes -
          Description 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 EBDF definition.


          In addition, CASE expressions are not allowed in subselects either, although the EBNF definition of the SimpleSelectExpression states that they should be.
          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.
          Guilherme Blanco made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Assignee Benjamin Eberlei [ beberlei ] Guilherme Blanco [ guilhermeblanco ]
          Fix Version/s 2.2-DEV [ 10157 ]
          Resolution Fixed [ 1 ]
          Benjamin Eberlei made changes -
          Workflow jira [ 12470 ] jira-feedback [ 14796 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback [ 14796 ] jira-feedback2 [ 16660 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback2 [ 16660 ] jira-feedback3 [ 18913 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved: