mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
AbstractQuery::getSingleScalarResult() throws NoResultException, even though it shouldn't #6342
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 @Piskvor on GitHub (Nov 14, 2019).
Bug Report
Summary
AbstractQuery::getSingleScalarResult() throws NoResultException, even though it shouldn't (by documentation and by code's apparent intent).
Current behavior
Calling getSingleScalarResult() on a query that returns an empty result set throws NoResultException.
How to reproduce
Expected behavior
Calling getSingleScalarResult() on a query that returns an empty result set returns NULL.
PR: https://github.com/doctrine/orm/pull/7895
@Ocramius commented on GitHub (Nov 14, 2019):
Is this a regression introduced by 2.6.3?
@Piskvor commented on GitHub (Nov 14, 2019):
Don't know - encountered this on 2.6.3, I will check. From a cursory glance, it seems that it's been for a while with
executeUsingQueryCache(), and that it only affects a cached result: in that case, it doesn't seem tosetHydrationMode().@webbiedave commented on GitHub (Apr 18, 2022):
The doc comment specifies that the exception will be thrown and projects over the years may be coded to depend on it:
At this point, if disabling the exception is desired, it may be best to allow that via function parameter or configuration.