Skip to content
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

fix: error where eager relations in a lazy-loaded entity would be undefined #8564

Merged
merged 1 commit into from Jan 31, 2022
Merged

fix: error where eager relations in a lazy-loaded entity would be undefined #8564

merged 1 commit into from Jan 31, 2022

Conversation

Bartmr
Copy link
Contributor

@Bartmr Bartmr commented Jan 25, 2022

Description of change

Given the scenario:

Entity A {
  id
  b: any type of relationship to Entity B | lazy
}

Entity B {
  id
  c: any type of relationship to something else | eager
  d: any type of relationship to something else | eager
}

this change intends to fix a bug that happens when lazy-loading a relationship with await entityA.b. All eager relations from Entity B are not loaded, and are set as undefined. This happens with all find methods and the Query Builder, breaking type-safety, specially for people using strictNullChecks in tsconfig.

Fixes #8328 #7841 (comment)

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • 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

@Bartmr Bartmr changed the title Fix error where eager relations in a lazy-loaded entity would be undefined fix: error where eager relations in a lazy-loaded entity would be undefined Jan 28, 2022
@pleerock pleerock merged commit 1cfd7b9 into typeorm:master Jan 31, 2022
@pleerock
Copy link
Member

Thank you for contribution! 🎉

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.

A lazy relation never loads a eager before that
2 participants