Alex
Alex

Reputation: 435

Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ','

It's about Doctrine and the TIMESTAMPDIFF function from the Oro Doctrine Extensions library.

Some code:

    $qb = $em->createQueryBuilder();
    $totalLogedTime  = $qb
                ->select('SUM(TIMESTAMPDIFF(MINUTE, ulr.logedIn, ulr.logedOut)) as sum')
                ->from('SDUserBundle:UserLoginRecord', 'ulr')
                ->where ...

config.yml

            dql:
                string_functions:
                    array_to_string: ITDoors\CommonBundle\DQL\ArrayToStringDQL
                    array: ITDoors\CommonBundle\DQL\ArrayDQL
                    select_next_handling_message_date: SD\CommonBundle\DQL\SelectNextHandlingMessageDateDQL
                    cast: Oro\ORM\Query\AST\Functions\Cast
                datetime_functions:
                    date:  Oro\ORM\Query\AST\Functions\SimpleFunction
                numeric_functions:
                    dayofyear: Oro\ORM\Query\AST\Functions\SimpleFunction
                    year: Oro\ORM\Query\AST\Functions\SimpleFunction
                    month: Oro\ORM\Query\AST\Functions\SimpleFunction
                    day: Oro\ORM\Query\AST\Functions\SimpleFunction
                    timestampdiff: Oro\ORM\Query\AST\Functions\SimpleFunction
                    date: Oro\ORM\Query\AST\Functions\SimpleFunction

Error:

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

DQL:

SELECT SUM(TIMESTAMPDIFF(MINUTE, ulr.logedIn, ulr.logedOut)) FROM SDUserBundle:UserLoginRecord ulr WHERE ulr.user_id = 353 AND ulr.logedIn > :start AND ulr.logedOut < :end
                               ^ - col 31

What's wrong? Thanks.

Upvotes: 2

Views: 13498

Answers (1)

sjagr
sjagr

Reputation: 16502

Your timestampdiff configuration declaration is incorrect. You must use this parameter instead, as per the README:

doctrine:
    orm:
        dql:
            numeric_functions:
                timestampdiff:  Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff

The reason the error message expects a closing ) bracket is because the SimpleFunction is a one-parameter function and doesn't accept multiple arguments, so a , (comma) is never expected.

Upvotes: 3

Related Questions