Skip to content

QueryBuilder left join the same table twice bug #2602

@deemaagog

Description

@deemaagog

Hi! thanks a bunch for this awesome ORM!
Describe the bug
I'm trying to join the same table twice (this is a simplified example)

const qb = await this.patternRepository
      .createQueryBuilder('patterns')
      .select(['patterns.id', 'user.id', 'user2.id'])
      .leftJoin('patterns.user', 'user')
      .leftJoin('patterns.user', 'user2')
      .getResultList();

and getting an error
invalid reference to FROM-clause entry for table "user"

this is the resulted sql query, seems like one left join is missing

select "patterns"."id", "user"."id", "user2"."id" from "pattern" as "patterns" left join "user" as "user2" on "patterns"."userId" = "user2"."id"

Expected behavior
No error

Versions

Dependency Version
node 14
typescript 4.1.3
mikro-orm 5
your-driver postgresql

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions