Skip to content

Clarify that "query_builder" must have displayed entity in from() #4331

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

Closed
webmozart opened this issue Oct 17, 2014 · 5 comments
Closed

Clarify that "query_builder" must have displayed entity in from() #4331

webmozart opened this issue Oct 17, 2014 · 5 comments
Labels
actionable Clear and specific issues ready for anyone to take them. Doctrine good first issue Ideal for your first contribution! (some Symfony experience may be required)

Comments

@webmozart
Copy link
Contributor

We had this "bug report":

$qb = $this->getEntityManager()->createQueryBuilder();
$qb
    ->select('DISTINCT b')
    ->from('TestBundle:EntityA', 'a')
    ->innerJoin('TestBundle:EntityB', 'b', Expr\Join::WITH, $qb->expr()->eq('a.key', 'b'))
    ->where(
        $qb->expr()->eq('b.flag', ':flagValue')
    )
    ->setParameter('flagValue', 1)
;

The problem here is that the select() does not select from the from() table, but the joined one. The documentation should clarify that the select() should go to the from() table only for entity fields.

@wouterj wouterj added actionable Clear and specific issues ready for anyone to take them. Doctrine and removed actionable Clear and specific issues ready for anyone to take them. labels Oct 18, 2014
@wouterj
Copy link
Member

wouterj commented Oct 18, 2014

I think this is out of scope for the symfony documentation. We aren't documenting Doctrine, we are only documenting the Symfony integration of Doctrine.
Doctrine should make sure they documented this.

@webmozart
Copy link
Contributor Author

I disagree. The issue is Symfony's because we explicitly fetch the choices using the ID field in the root table.

@xabbuh
Copy link
Member

xabbuh commented Oct 25, 2014

@webmozart So, do I understand correctly that one should select a in your example because that selected object is later on used in the Form component to compare choices?

@webmozart
Copy link
Contributor Author

@xabbuh yes, exactly

@wouterj
Copy link
Member

wouterj commented Oct 25, 2014

Ah, I'm sorry @webmozart you are correct. I did not see the referenced issue and thought you were talking about doctrine only (not integrated in the forms).

@wouterj wouterj added actionable Clear and specific issues ready for anyone to take them. good first issue Ideal for your first contribution! (some Symfony experience may be required) labels May 2, 2015
@xabbuh xabbuh closed this as completed in a8c0d99 Dec 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Doctrine good first issue Ideal for your first contribution! (some Symfony experience may be required)
Projects
None yet
Development

No branches or pull requests

3 participants