$qb->expr()->countDistinct() fails with multiple values
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
Still not solved? Any work around?
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))
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
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