Skip to content

Commit

Permalink
fix: resolve issue with find with relations returns soft-deleted enti…
Browse files Browse the repository at this point in the history
…ties

This new feature changes the behavior of typeorm to allow avoiding entities that have soft delete
close: typeorm#6265
  • Loading branch information
luiseariass authored and luiseariasss committed Jan 19, 2021
1 parent af2c5c4 commit 2f245e0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/query-builder/SelectQueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,10 @@ export class SelectQueryBuilder<Entity> extends QueryBuilder<Entity> implements
this.expressionMap.joinAttributes.push(joinAttribute);

if (joinAttribute.metadata) {

if (joinAttribute.metadata.deleteDateColumn && !this.expressionMap.withDeleted) {
const conditionDeleteColumn = `${aliasName}.${joinAttribute.metadata.deleteDateColumn.propertyName} is null`;
joinAttribute.condition += joinAttribute.condition ? ` and ${conditionDeleteColumn}`: `${conditionDeleteColumn}`;
}
// todo: find and set metadata right there?
joinAttribute.alias = this.expressionMap.createAlias({
type: "join",
Expand Down

0 comments on commit 2f245e0

Please sign in to comment.