Skip to content

Conversation

@carantunes
Copy link

Proves #9395

Description of change

Test case to showcase the bug.
From the docs https://typeorm.io/find-options, the following query

userRepository.find({
    relations: {
        project: true,
    },
    where: {
        project: {
            name: "TypeORM",
            initials: "TORM",
        },
    },
})

should execute

SELECT * FROM "user"
LEFT JOIN "project" ON "project"."id" = "user"."projectId"
WHERE "project"."name" = 'TypeORM' AND "project"."initials" = 'TORM'

But in reality in executing

SELECT * FROM "user"
INNER JOIN "project" ON "project"."id" = "user"."projectId"
WHERE "project"."name" = 'TypeORM' AND "project"."initials" = 'TORM'

which is a problem for optional relations.

Further investigation showed LEFT is only replaced by INNER when we query by a relation property, eg if we query relation with IsNull, join in still of type LEFT.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

@carantunes carantunes changed the title issue/9395 Test case to show issue/9395 Sep 26, 2022
Copy link

@PedroLimaComputacao PedroLimaComputacao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be post4 instead of post1 or post3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants