getOneOrNullResult should not throw an exception when having more than one result #6347

Closed
opened 2026-01-22 15:31:29 +01:00 by admin · 1 comment
Owner

Originally created by @crtl on GitHub (Nov 22, 2019).

Originally assigned to: @Ocramius on GitHub.

Feature Request

Q A
New Feature no
RFC yes
BC Break ?

Summary

When calling AbstractQuery::getOneOrNullResult while having more than one result, results in an exception being thrown:

In AbstractQuery.php line 780: More than one result was found for query although one row or none was expected.

Either the method name or the exception is wrong.
Why should an exception be thrown when I get more than one result?

Originally created by @crtl on GitHub (Nov 22, 2019). Originally assigned to: @Ocramius on GitHub. ### Feature Request <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | New Feature | no | RFC | yes | BC Break | ? #### Summary When calling `AbstractQuery::getOneOrNullResult` while having more than one result, results in an exception being thrown: ``` In AbstractQuery.php line 780: More than one result was found for query although one row or none was expected. ``` Either the method name or the exception is wrong. Why should an exception be thrown when I get more than one result?
admin added the ImprovementWon't FixQuestionDQL labels 2026-01-22 15:31:29 +01:00
admin closed this issue 2026-01-22 15:31:30 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 22, 2019):

This is by design: a query that is supposed to retrieve one or zero results produced more results, and it should indeed throw (unexpected).

@Ocramius commented on GitHub (Nov 22, 2019): This is by design: a query that is supposed to retrieve one or zero results produced more results, and it should indeed throw (unexpected).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6347