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

TreeRepository findDescendants returns everything if parent does not exist or deleted #8556

Closed
astritsh opened this issue Jan 22, 2022 · 2 comments · Fixed by #8557
Closed

Comments

@astritsh
Copy link
Contributor

astritsh commented Jan 22, 2022

Issue Description

findDescendants of TreeRepository using materialised-path design returns everything if parent was deleted before getting children or if we query with a non existing parent id.

In my case when deleting children of a parent that was already deleted I ended up deleting everything from the tree entity table(quite dangerous!).

Expected Behavior

findDescendants should return empty for a non existing parent.

Actual Behavior

findDescendants is returning all tree entity records from database if we query with a non existing parent id.

Steps to Reproduce

  1. Save a tree entity parent on db.(e.g saved id is 1)
  2. findDescendants({id: -1})(using a non existing id-1)
  3. parent with id: 1 saved in step 1 is being returned
// insert code here

My Environment

NestJs.

Dependency Version
Operating System
Node.js version 12.14.1
Typescript version x.y.zzz
TypeORM version 0.2.41

Additional Context

Relevant Database Driver(s)

DB Type Reproducible
aurora-data-api no
aurora-data-api-pg no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql yes
nativescript no
oracle no
postgres yes
react-native no
sap no
sqlite no
sqlite-abstract no
sqljs no
sqlserver yes

Are you willing to resolve this issue by submitting a Pull Request?

  • ✅ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
astritsh pushed a commit to astritsh/typeorm that referenced this issue Jan 22, 2022
pleerock pushed a commit that referenced this issue Jan 31, 2022
* fix: find descendants of a non-existing tree parent

Closes: #8556

* Change default connection name(try another build)

Co-authored-by: Astrit Shehu <a.shehu@linkplus-ks.com>
@Yuvraj102
Copy link

Hello Authors, Can you please point a resource for detailed implementation of materialised path in typeorm ???, the document is very short on this topic and doesn't cover the implementation in detail.

@ashokars
Copy link

Tree entity document should be detailed

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

Successfully merging a pull request may close this issue.

3 participants