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

doctrinebot opened this Issue May 1, 2012 · 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 https://gist.github.com/2473775 ), results in different fetched association:

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

SQL without join:
SELECT a0.a_id AS a_id0, a0_.id 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 a.id = :id

SQL with fetch join:
SELECT a0.a_id AS a_id0, b1_.id AS id1, b1_.name AS name2, a0_.id AS id3 FROM a a0_ LEFT JOIN b b1_ ON a0_.id = b1_.id 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 Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment