@punks/backend-entity-manager 0.0.320 → 0.0.321

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,4 +7,5 @@ export declare class QueryClauseBuilder {
7
7
  numericFilter(filter: NumericFilter): FindOperator<number>;
8
8
  dateFilter(filter: DateFilter): FindOperator<Date>;
9
9
  boolFilter(filter: BooleanFilter): FindOperator<boolean>;
10
+ private buildInClause;
10
11
  }
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Log, csvParse, excelParse, excelBuild, csvBuild, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, toDict, sort, byField, toArrayDict, toItemsDict, ensureTailingSlash, ensureStartSlash, removeUndefinedProps, sleep } from '@punks/backend-core';
2
- import { MoreThanOrEqual, In, Equal, Not, IsNull, And, MoreThan, LessThanOrEqual, LessThan, ILike, Repository } from 'typeorm';
2
+ import { MoreThanOrEqual, Equal, Not, IsNull, And, MoreThan, LessThanOrEqual, LessThan, ILike, In, Or, Repository } from 'typeorm';
3
3
  import { applyDecorators, Injectable, SetMetadata, createParamDecorator, Global, Module, Scope, Inject, Logger, StreamableFile, HttpException, HttpStatus } from '@nestjs/common';
4
4
  import { Reflector } from '@nestjs/core';
5
5
  import { AsyncLocalStorage } from 'async_hooks';
@@ -2954,7 +2954,7 @@ class QueryClauseBuilder {
2954
2954
  enumFilter(filter) {
2955
2955
  const clauses = [];
2956
2956
  if (!isNullOrUndefined(filter?.in)) {
2957
- clauses.push(In(filter.in));
2957
+ clauses.push(this.buildInClause(filter.in));
2958
2958
  }
2959
2959
  if (!isNullOrUndefined(filter?.eq)) {
2960
2960
  clauses.push(Equal(filter.eq));
@@ -2963,7 +2963,7 @@ class QueryClauseBuilder {
2963
2963
  clauses.push(Not(Equal(filter.ne)));
2964
2964
  }
2965
2965
  if (!isNullOrUndefined(filter?.notIn)) {
2966
- clauses.push(Not(In(filter.notIn)));
2966
+ clauses.push(Not(this.buildInClause(filter.notIn)));
2967
2967
  }
2968
2968
  if (filter?.isNull === true) {
2969
2969
  clauses.push(IsNull());
@@ -2976,7 +2976,7 @@ class QueryClauseBuilder {
2976
2976
  idFilter(filter) {
2977
2977
  const clauses = [];
2978
2978
  if (!isNullOrUndefined(filter?.in)) {
2979
- clauses.push(In(filter.in));
2979
+ clauses.push(this.buildInClause(filter.in));
2980
2980
  }
2981
2981
  if (!isNullOrUndefined(filter?.eq)) {
2982
2982
  clauses.push(Equal(filter.eq));
@@ -2985,7 +2985,7 @@ class QueryClauseBuilder {
2985
2985
  clauses.push(Not(Equal(filter.ne)));
2986
2986
  }
2987
2987
  if (!isNullOrUndefined(filter?.notIn)) {
2988
- clauses.push(Not(In(filter.notIn)));
2988
+ clauses.push(Not(this.buildInClause(filter.notIn)));
2989
2989
  }
2990
2990
  if (filter?.isNull === true) {
2991
2991
  clauses.push(IsNull());
@@ -3010,7 +3010,7 @@ class QueryClauseBuilder {
3010
3010
  clauses.push(LessThan(filter.lt));
3011
3011
  }
3012
3012
  if (!isNullOrUndefined(filter?.in)) {
3013
- clauses.push(In(filter.in));
3013
+ clauses.push(this.buildInClause(filter.in));
3014
3014
  }
3015
3015
  if (!isNullOrUndefined(filter?.eq)) {
3016
3016
  clauses.push(Equal(filter.eq));
@@ -3028,7 +3028,7 @@ class QueryClauseBuilder {
3028
3028
  clauses.push(Not(ILike(filter.ine)));
3029
3029
  }
3030
3030
  if (!isNullOrUndefined(filter?.notIn)) {
3031
- clauses.push(Not(In(filter.notIn)));
3031
+ clauses.push(Not(this.buildInClause(filter.notIn)));
3032
3032
  }
3033
3033
  if (!isNullOrUndefined(filter?.notLike)) {
3034
3034
  clauses.push(Not(ILike(filter.notLike.replaceAll("*", "%"))));
@@ -3056,10 +3056,10 @@ class QueryClauseBuilder {
3056
3056
  clauses.push(LessThan(filter.lt));
3057
3057
  }
3058
3058
  if (!isNullOrUndefined(filter?.in)) {
3059
- clauses.push(In(filter.in ?? []));
3059
+ clauses.push(this.buildInClause(filter.in ?? []));
3060
3060
  }
3061
3061
  if (!isNullOrUndefined(filter?.notIn)) {
3062
- clauses.push(Not(In(filter.notIn)));
3062
+ clauses.push(Not(this.buildInClause(filter.notIn)));
3063
3063
  }
3064
3064
  if (!isNullOrUndefined(filter?.eq)) {
3065
3065
  clauses.push(Equal(filter.eq));
@@ -3109,13 +3109,20 @@ class QueryClauseBuilder {
3109
3109
  clauses.push(Not(IsNull()));
3110
3110
  }
3111
3111
  if (!isNullOrUndefined(filter?.in)) {
3112
- clauses.push(In(filter.in ?? []));
3112
+ clauses.push(this.buildInClause(filter.in ?? []));
3113
3113
  }
3114
3114
  if (!isNullOrUndefined(filter?.notIn)) {
3115
- clauses.push(Not(In(filter.notIn)));
3115
+ clauses.push(Not(this.buildInClause(filter.notIn)));
3116
3116
  }
3117
3117
  return And(...clauses);
3118
3118
  }
3119
+ buildInClause(values) {
3120
+ const containsNulls = values.some((v) => isNullOrUndefined(v));
3121
+ if (!containsNulls) {
3122
+ return In(values);
3123
+ }
3124
+ return Or(In(values.filter((v) => !isNullOrUndefined(v))), IsNull());
3125
+ }
3119
3126
  }
3120
3127
 
3121
3128
  class PermissionsChecker {