$qb->expr()->countDistinct() fails with multiple values #4929

Open
opened 2026-01-22 14:52:18 +01:00 by admin · 4 comments
Owner

Originally created by @greeny on GitHub (Dec 10, 2015).

I have $qb (QueryBuilder), and i call this:

$qb->expr()->countDistinct('e.name', 'e.value')

Generated SQL / DQL is valid, but Parser complains about syntax error:

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

In tests, there is a test for multiple arguments in countDistinct(), but no test for Parser accepting multiple arguments for COUNT(DISTINCT

Originally created by @greeny on GitHub (Dec 10, 2015). I have $qb (QueryBuilder), and i call this: `$qb->expr()->countDistinct('e.name', 'e.value')` Generated SQL / DQL is valid, but Parser complains about syntax error: `Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ','` In tests, there is a test for multiple arguments in `countDistinct()`, but no test for Parser accepting multiple arguments for `COUNT(DISTINCT`
Author
Owner

@oskargunther commented on GitHub (Jan 20, 2018):

Still not solved? Any work around?

@oskargunther commented on GitHub (Jan 20, 2018): Still not solved? Any work around?
Author
Owner

@lart2150 commented on GitHub (Feb 9, 2018):

I found a major hack of a workaround. If you combine the two fields and then select distinct of the two it works.
COUNT(DISTINCT CONCAT(ps.date, s.id))

@lart2150 commented on GitHub (Feb 9, 2018): I found a major hack of a workaround. If you combine the two fields and then select distinct of the two it works. `COUNT(DISTINCT CONCAT(ps.date, s.id))`
Author
Owner

@lcobucci commented on GitHub (Feb 22, 2018):

It would be amazing if someone could send us a failing test case that reproduces that behaviour. It would help us a lot to identify and fix the issue you're describing.

You can find examples on 388afb46d0/tests/Doctrine/Tests/ORM/Functional/Ticket

@lcobucci commented on GitHub (Feb 22, 2018): It would be amazing if someone could send us a failing test case that reproduces that behaviour. It would help us a lot to identify and fix the issue you're describing. You can find examples on https://github.com/doctrine/doctrine2/tree/388afb46d0cb3ed0c51332e8df0de9e942c2690b/tests/Doctrine/Tests/ORM/Functional/Ticket
Author
Owner

@peter-gribanov commented on GitHub (Jan 2, 2025):

It would be amazing if someone could send us a failing test case that reproduces that behaviour. It would help us a lot to identify and fix the issue you're describing.

@lcobucci necro post #8058

@peter-gribanov commented on GitHub (Jan 2, 2025): > It would be amazing if someone could send us a failing test case that reproduces that behaviour. It would help us a lot to identify and fix the issue you're describing. @lcobucci necro post #8058
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4929