Skip to content

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

Closed
@webmozart

Description

@webmozart

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoctrineactionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions