mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-208: AbstractQuery::getSingleResult() should throw exception if no row is found #258
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 @doctrinebot on GitHub (Dec 12, 2009).
Jira issue originally created by user @beberlei:
AbstractQuery::getSingleResult() should throw exception if no row is found.
This is also what JPA does, it throws a NoResultException, so we should add a Doctrine\ORM\NoResultException for this.
@doctrinebot commented on GitHub (Dec 12, 2009):
Comment created by @beberlei:
This probably also affects EntityManager::find($class, $identifier) and EntityRepository::find($class, $identifier)
@doctrinebot commented on GitHub (Dec 12, 2009):
Comment created by romanb:
As was discussed, find() should rather return the entity or null, if it was not found, since find() implies that you're not sure it is there.
Contrary to that, getSingleResult() is a strong assumption about the fact that there is a result and thus no result is usually unexpected behavior. Hence in this case an exception might be the better fit.
@doctrinebot commented on GitHub (Dec 18, 2009):
Issue was closed with resolution "Fixed"