Skip to content

Loading…

DDC-208: AbstractQuery::getSingleResult() should throw exception if no row is found #2762

Closed
doctrinebot opened this Issue · 3 comments

1 participant

@doctrinebot

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

Comment created by @beberlei:

This probably also affects EntityManager::find($class, $identifier) and EntityRepository::find($class, $identifier)

@doctrinebot

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

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.0-ALPHA4 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.