Skip to content

Commit

Permalink
fix(core): Add usage check of nested custom property filters in ListQ…
Browse files Browse the repository at this point in the history
…ueryBuilder (#2939)

Co-authored-by: Edgars Jegorovs <edgars.jegorovs@pearlgroup.no>
  • Loading branch information
jegorovedgar and Edgars Jegorovs authored Jul 12, 2024
1 parent eefe896 commit 05cfc9d
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,19 @@ export class ListQueryBuilder implements OnApplicationBootstrap {
}

private customPropertyIsBeingUsed(property: string, options: ListQueryOptions<any>): boolean {
return !!(options.sort?.[property] || options.filter?.[property]);
return !!(options.sort?.[property] || this.isPropertyUsedInFilter(property, options.filter));
}

private isPropertyUsedInFilter(
property: string,
filter?: NullOptionals<FilterParameter<any>> | null,
): boolean {
return !!(
filter &&
(filter[property] ||
filter._and?.some(nestedFilter => this.isPropertyUsedInFilter(property, nestedFilter)) ||
filter._or?.some(nestedFilter => this.isPropertyUsedInFilter(property, nestedFilter)))
);
}

/**
Expand Down

0 comments on commit 05cfc9d

Please sign in to comment.