-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed as not planned
Labels
Description
There are two ways to join entities and both can be restricted further using the WITH keyword:
- using join assocations.
SELECT u, a FROM App\Entity\User u JOIN u.addresses a WITH a.country = 'DE'
- using range variable declaration:
SELECT u, a FROM App\Entity\User u JOIN App\Entity\Address a WITH u.id = a.user AND a.country = 'DE'
The first one will fetch all addresses into the collection User::$addresses, the second one will cause a mixed result to emit both entities at the same time.
Case 1 will causes problems, because looking at a collection, you never know if its fully or only partially loaded. And reloading the collection is also not possible in a meaningful way. See this comment #2878 (comment)
As such, we are looking to deprecate and remove case 1, and also deprecate restricting by an association that is fetched joined, say:
SELECT u, a FROM App\Entity\User u JOIN u.addresses a WHERE a.country = 'DE'
What the users mean to do is probably this:
SELECT u, a FROM App\Entity\User u JOIN u.addresses a WHERE u.id IN (SELECT a2.user FROM App\Entity\Address a2 WHERE a2.country = 'DE')
Reactions are currently unavailable