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: findRoots should get the defined primary key column #6982

Merged
merged 2 commits into from
Oct 30, 2020

Conversation

ilyasfoo
Copy link
Contributor

@ilyasfoo ilyasfoo commented Oct 28, 2020

Description of change

Previously findRoots assumes the primary column of an entity to be named id

const parentPropertyName = this.manager.connection.namingStrategy.joinColumnName(
this.metadata.treeParentRelation!.propertyName, "id"
);

This PR will instead use the column defined by entity class

Fixes #6948, #2361

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
  • The new commits follow conventions explained in CONTRIBUTING.md

@imnotjames imnotjames added the hacktoberfest-accepted label hacktoberfest label Oct 29, 2020
@pleerock pleerock merged commit f2ba901 into typeorm:master Oct 30, 2020
@pleerock
Copy link
Member

Thank you!

dolsup pushed a commit to dolsup/typeorm that referenced this pull request Nov 3, 2020
* test: added failing test for github issue typeorm#6948

* fix: findRoots should get the actual primary key column, fixes typeorm#6948
zaro pushed a commit to zaro/typeorm that referenced this pull request Jan 12, 2021
* test: added failing test for github issue typeorm#6948

* fix: findRoots should get the actual primary key column, fixes typeorm#6948
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted label hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TreeRepository's findRoots query incorrectly when using a custom primary key
3 participants