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: mongodb repository.find filters soft deleted rows #8581

Merged
merged 1 commit into from Feb 15, 2022
Merged

fix: mongodb repository.find filters soft deleted rows #8581

merged 1 commit into from Feb 15, 2022

Conversation

spotykatch
Copy link
Contributor

@spotykatch spotykatch commented Jan 28, 2022

Closes: #7113

Description of change

MongoRepository find, findAndCount, findByIds, findOne methods do not select rows that was soft deleted.

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

@spotykatch spotykatch marked this pull request as ready for review January 28, 2022 18:07
@spotykatch spotykatch marked this pull request as draft January 28, 2022 18:07
@spotykatch
Copy link
Contributor Author

Tests are failing with #8567 😄

@@ -744,4 +770,8 @@ export class MongoEntityManager extends EntityManager {
};
}

protected filterSoftDeleted<Entity>(cursor: Cursor<Entity>, deleteDateColumn: ColumnMetadata) {
cursor.filter({$where: `this.${deleteDateColumn.propertyName}==null`});
Copy link
Member

Choose a reason for hiding this comment

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

Does filter mutate the original cursor ?

Copy link
Contributor Author

@spotykatch spotykatch Feb 1, 2022

Choose a reason for hiding this comment

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

It does.

Cursor.prototype.filter = function(filter) {
  if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true});
  this.s.cmd.query = filter;
  return this;
}

@spotykatch spotykatch marked this pull request as ready for review February 3, 2022 15:18
@pleerock pleerock merged commit f7c1f7d into typeorm:master Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Soft deleted docs still being pulled in Mongodb
3 participants