Skip to content

Deprecate JOIN ... WITH keyword for join associations #10978

@beberlei

Description

@beberlei

There are two ways to join entities and both can be restricted further using the WITH keyword:

  1. using join assocations.
SELECT u, a FROM App\Entity\User u JOIN u.addresses a WITH a.country = 'DE'
  1. 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')

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions