Skip to content


DDC-1806: DQL with and without fetch join cause #2462

doctrinebot opened this Issue · 2 comments

2 participants


Jira issue originally created by user @ocramius:

When running following DQL in newly cleared EntityManager, with the provided entities (see attached archive or gist at ), results in different fetched association:

DQL without join:
SELECT a FROM Entity\A a WHERE = :id

SQL without join:
SELECT a0.a_id AS a_id0, AS id1 FROM a a0_ WHERE a0_.aid = ?

Result without join:
$query->getOneOrNullResult()->getB()->getName(); // 'correct'

DQL with fetch join:
SELECT a, b FROM Entity\A a LEFT JOIN a.b b WHERE = :id

SQL with fetch join:
SELECT a0.a_id AS a_id0, AS id1, AS name2, AS id3 FROM a a0_ LEFT JOIN b b1_ ON = WHERE a0_.aid = ?

Result with fetch join:
$query->getOneOrNullResult()->getB()->getName(); // 'wrong' (different result)

The problem seems to be strictly related with how the @JoinColumn is configured.

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added the Bug label
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.