Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ORM] EntityResult doesn't handle single results #37

Closed
kbond opened this issue Feb 28, 2024 · 0 comments
Closed

[ORM] EntityResult doesn't handle single results #37

kbond opened this issue Feb 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@kbond
Copy link
Member

kbond commented Feb 28, 2024

Consider a delete where the result is the # of deleted rows.

$result = EntityResultQueryBuilder::forEntity($this->em(), Order::class, 'o')
    ->delete()
    ->where('o.lastSyncedAt < :date')
    ->setParameter('date', new \DateTimeImmutable('-25 years'))
    ->result()
    ->asInt()
    ->first() // expect int but is null
;

The query is run successfully but because of the logic in EntityResult::first(), the exception is swallowed and the $default is returned.

Todo:

  • Enable this behaviour (above example should return int)
  • Throw specific exception when trying to iterate but the result isn't a collection.
@kbond kbond added the bug Something isn't working label Feb 28, 2024
@kbond kbond closed this as completed Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant