Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1523

Coalesce() does not work with functions

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.1.4
    • Fix Version/s: 2.2
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None

      Description

      I wanted to use COALESCE in DQL with a function (e.g. CURRENT_TIMESTAMP()). If I run this DQL, I receive a syntax error exception like this one:

      montbook:marlow mprebio$ php scripts/doctrine.php orm:run-dql "select COALESCE(CURRENT_TIMESTAMP()) from Project\Entity\User user"

      [Doctrine\ORM\Query\QueryException]
      [Syntax Error] line 0, col 33: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got '('

      I've traced this error to Doctrine\ORM\Parser::ScalarExpression() which tries to interpret the current_timestamp function as a SimpleArithmeticExpression or as a StateFieldPathExpression (first if). As far as I understand this part of the parser, the function call should lead to the if part with $this->_isFunction(). Therefore I added a "and !$this->_isFunction()" to the first if clause. After this change everything works as expected: The above query returns the current timestamp (many times because of the from since DQL needs a from part).

      Reordering the ifs should work too.

        Activity

        Martin Prebio created issue -
        Hide
        Martin Prebio added a comment -

        Also the documentation at http://www.doctrine-project.org/docs/orm/2.1/en/ only mentions COALESCE in the EBNF but not in the real documentation part. At first I thought that Doctrine doesn't support coalesce at all.

        Show
        Martin Prebio added a comment - Also the documentation at http://www.doctrine-project.org/docs/orm/2.1/en/ only mentions COALESCE in the EBNF but not in the real documentation part. At first I thought that Doctrine doesn't support coalesce at all.
        Hide
        Guilherme Blanco added a comment -

        COALESCE does not exist on 2.1.
        COALESCE is a 2.2-DEV, so use latest master.

        Marking as invalid, since we won't change 2.1 to support this.

        Show
        Guilherme Blanco added a comment - COALESCE does not exist on 2.1. COALESCE is a 2.2-DEV, so use latest master. Marking as invalid, since we won't change 2.1 to support this.
        Guilherme Blanco made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Benjamin Eberlei [ beberlei ] Guilherme Blanco [ guilhermeblanco ]
        Fix Version/s 2.2-DEV [ 10157 ]
        Resolution Invalid [ 6 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 13247 ] jira-feedback [ 15136 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 15136 ] jira-feedback2 [ 17000 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17000 ] jira-feedback3 [ 19253 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1523, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Martin Prebio
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: