mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Error if use IN-clause inside a SUM function #6140
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @webgnome on GitHub (Dec 19, 2018).
Originally assigned to: @Ocramius on GitHub.
I want to order my result by by the sum of condition matches
SUM(some_column IN (val1, val2, val3))As i understand the code of symfonys doctrine Bundle the "AVG" | "MAX" | "MIN" | "SUM" | "COUNT functions do only except DISTINCT inside the sum parenthesis.
At the moment i use
entityManager->getConnection()->prepare(...) ...->execute ...After that i have to do a second call over the repository class
@Ocramius commented on GitHub (Dec 19, 2018):
Correct,
DISTINCTisn't allowed there.It is OK to use SQL for such computations
It's a
won't fixupfront, sinceSUM(expr)is not really supported by all vendors. If you want to support it, you'd start by providing test scenarios, and verifying that they run on all DBAL platforms.Meanwhile, closing here, since relying on SQL is an acceptable/simple tradeoff.