From 05cfc9da07714b906def0ded0ce56ab15e087a35 Mon Sep 17 00:00:00 2001 From: Edgar Jegorov Date: Fri, 12 Jul 2024 11:54:01 +0300 Subject: [PATCH] fix(core): Add usage check of nested custom property filters in ListQueryBuilder (#2939) Co-authored-by: Edgars Jegorovs --- .../list-query-builder/list-query-builder.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/core/src/service/helpers/list-query-builder/list-query-builder.ts b/packages/core/src/service/helpers/list-query-builder/list-query-builder.ts index 8f4bce2edd..c434cbb14b 100644 --- a/packages/core/src/service/helpers/list-query-builder/list-query-builder.ts +++ b/packages/core/src/service/helpers/list-query-builder/list-query-builder.ts @@ -427,7 +427,19 @@ export class ListQueryBuilder implements OnApplicationBootstrap { } private customPropertyIsBeingUsed(property: string, options: ListQueryOptions): boolean { - return !!(options.sort?.[property] || options.filter?.[property]); + return !!(options.sort?.[property] || this.isPropertyUsedInFilter(property, options.filter)); + } + + private isPropertyUsedInFilter( + property: string, + filter?: NullOptionals> | null, + ): boolean { + return !!( + filter && + (filter[property] || + filter._and?.some(nestedFilter => this.isPropertyUsedInFilter(property, nestedFilter)) || + filter._or?.some(nestedFilter => this.isPropertyUsedInFilter(property, nestedFilter))) + ); } /**