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: find descendants of a non-existing tree parent #8557

Merged
merged 2 commits into from Jan 31, 2022

Conversation

astritsh
Copy link
Contributor

@astritsh astritsh commented Jan 22, 2022

Closes: #8556

Description of change

If subquery in findDescendants CONCAT(${subQuery.getQuery()}, '%') returns null when entity parent does not exist, the search string becomes LIKE '%', because CONCAT ignores NULL. This LIKE '%' results on returning everything instead of nothing.
Now with NULLIF fix, search will be LIKE NULL, which returns nothing for a non existing tree parent.
In case of Sqlite, LIKE ${subQuery.getQuery()} || '%' is already evaluated as LIKE NULL when subquery returns null.

Pull-Request Checklist

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

@pleerock pleerock merged commit cbb61eb 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.

TreeRepository findDescendants returns everything if parent does not exist or deleted
3 participants