typeorm-extensions 2.2.0-rc.8 → 2.2.0-rc.9

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.
Files changed (62) hide show
  1. package/README.md +0 -8
  2. package/dist/extensions/calculated-column.extension.d.ts +3 -3
  3. package/dist/extensions/calculated-column.extension.js +3 -16
  4. package/dist/extensions/cursor-pagination.extension.js +3 -11
  5. package/dist/extensions/get-many-with-totals.extension.js +4 -20
  6. package/dist/extensions/join-lateral.extension.js +4 -6
  7. package/dist/extensions/period-filter.extension.js +1 -11
  8. package/dist/extensions/typed/index.d.ts +1 -0
  9. package/dist/extensions/typed/index.js +1 -0
  10. package/dist/extensions/typed/typed-calculated/typed-calculated-column.extension.d.ts +25 -0
  11. package/dist/extensions/typed/typed-calculated/typed-calculated-column.extension.js +24 -0
  12. package/dist/extensions/typed/typed-having/typed-having.extension.js +1 -1
  13. package/dist/extensions/typed/typed-joins/typed-join-and-map.extension.js +11 -10
  14. package/dist/extensions/typed/typed-joins/typed-joins.extension.js +11 -22
  15. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.js +11 -17
  16. package/dist/extensions/typed/typed-returning/typed-returning.extension.js +1 -9
  17. package/dist/extensions/typed/typed-select/typed-select.extension.js +2 -8
  18. package/dist/extensions/typed/typed-where/typed-period-filter.extension.js +1 -11
  19. package/dist/extensions/typed/typed-where/typed-where-array.extension.js +4 -18
  20. package/dist/extensions/typed/typed-where/typed-where-ilike.extension.js +1 -11
  21. package/dist/extensions/typed/typed-where/typed-where-is-any.extension.js +3 -22
  22. package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.js +3 -22
  23. package/dist/extensions/typed/typed-where/typed-where-is-in.extension.js +3 -23
  24. package/dist/extensions/typed/typed-where/typed-where-json.extension.js +4 -23
  25. package/dist/extensions/typed/typed-where/typed-where-lower.extension.js +1 -11
  26. package/dist/extensions/typed/typed-where/typed-where-similar.extension.js +1 -10
  27. package/dist/extensions/typed/typed-where/typed-where.extension.js +2 -12
  28. package/dist/extensions/union.extension.js +1 -1
  29. package/dist/extensions/where-array.extension.js +1 -11
  30. package/dist/extensions/where-exists.extension.js +4 -15
  31. package/dist/extensions/where-is-any.extension.d.ts +38 -160
  32. package/dist/extensions/where-is-any.extension.js +1 -11
  33. package/dist/extensions/where-is-distinct-from.extension.js +1 -11
  34. package/dist/extensions/where-is-in.extension.d.ts +35 -145
  35. package/dist/extensions/where-is-in.extension.js +11 -29
  36. package/dist/extensions/where-json.extension.js +1 -11
  37. package/dist/extensions/where-relation-exists.extension.js +5 -25
  38. package/dist/index.d.ts +1 -6
  39. package/dist/index.js +1 -12
  40. package/dist/utils/calculated-column.utils.d.ts +8 -0
  41. package/dist/utils/calculated-column.utils.js +20 -3
  42. package/dist/utils/common.utils.d.ts +2 -0
  43. package/dist/utils/common.utils.js +4 -1
  44. package/dist/utils/cursor.utils.js +4 -6
  45. package/dist/utils/json-path.utils.js +2 -2
  46. package/dist/utils/pagination.utils.d.ts +5 -0
  47. package/dist/utils/pagination.utils.js +20 -10
  48. package/dist/utils/parameter.utils.d.ts +10 -0
  49. package/dist/utils/parameter.utils.js +22 -1
  50. package/dist/utils/period.utils.js +2 -1
  51. package/dist/utils/prototype.utils.d.ts +9 -0
  52. package/dist/utils/prototype.utils.js +12 -2
  53. package/dist/utils/query-builder.utils.d.ts +22 -2
  54. package/dist/utils/query-builder.utils.js +67 -44
  55. package/dist/utils/table.utils.js +9 -11
  56. package/dist/utils/time-zone.utils.d.ts +8 -0
  57. package/dist/utils/time-zone.utils.js +15 -5
  58. package/dist/utils/typed-where.utils.d.ts +9 -0
  59. package/dist/utils/typed-where.utils.js +17 -0
  60. package/dist/utils/where.utils.d.ts +2 -0
  61. package/dist/utils/where.utils.js +12 -14
  62. package/package.json +1 -1
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-is-in.extension");
4
- const typeorm_1 = require("typeorm");
5
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
6
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
7
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
8
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
9
7
  // patching
10
8
  const createWhereIsInTypedMethod = (method) => function (where, array) {
11
- return attachWhereIsIn(this, method, where, array);
9
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { value: array }, array);
12
10
  };
13
11
  const extension = {
14
12
  prototype: {
@@ -20,22 +18,4 @@ const extension = {
20
18
  orWhereIsNotInTyped: createWhereIsInTypedMethod('orWhereIsNotIn'),
21
19
  },
22
20
  };
23
- const queryBuilders = [
24
- typeorm_1.SelectQueryBuilder,
25
- typeorm_1.UpdateQueryBuilder,
26
- typeorm_1.DeleteQueryBuilder,
27
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
28
- ];
29
- queryBuilders.forEach((builder) => {
30
- (0, prototype_utils_1.patchPrototype)(builder, extension);
31
- });
32
- // implementation
33
- function attachWhereIsIn(builder, method, where, array) {
34
- if (typeof where === 'function') {
35
- // several columns have no single meaning (AND? OR?), and `where…` kept only the last one
36
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value: array });
37
- // .andWhere(`"table"."column" IN (:...values)`, { values: ['value'] })
38
- return builder[method](key, array);
39
- }
40
- return builder;
41
- }
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-json.extension");
4
- const typeorm_1 = require("typeorm");
5
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
6
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
7
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
8
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
9
7
  // patching
10
8
  const createWhereJsonTypedMethod = (method) => function (where, value) {
11
- return attachWhereJsonTyped(this, method, where, value);
9
+ // one signature for both: `value` is the JSON value or the key, each method checks its own
10
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { accessor: 'json' }, value);
12
11
  };
13
12
  const extension = {
14
13
  prototype: {
@@ -20,22 +19,4 @@ const extension = {
20
19
  orWhereJsonHasKeyTyped: createWhereJsonTypedMethod('orWhereJsonHasKey'),
21
20
  },
22
21
  };
23
- const queryBuilders = [
24
- typeorm_1.SelectQueryBuilder,
25
- typeorm_1.UpdateQueryBuilder,
26
- typeorm_1.DeleteQueryBuilder,
27
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
28
- ];
29
- queryBuilders.forEach((builder) => {
30
- (0, prototype_utils_1.patchPrototype)(builder, extension);
31
- });
32
- // implementation
33
- function attachWhereJsonTyped(builder, method, where, value) {
34
- if (typeof where !== 'function') {
35
- return builder;
36
- }
37
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { accessor: 'json' });
38
- // .andWhereJsonContains(`"table"."column"`, { role: 'admin' }) / .andWhereJsonHasKey(`"table"."column"`, 'role')
39
- // (one signature for both: `value` is the JSON value or the key, each method checks its own)
40
- return builder[method](key, value);
41
- }
22
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
5
3
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
7
5
  const sql_utils_1 = require("../../../utils/sql.utils");
@@ -56,15 +54,7 @@ const extension = {
56
54
  orWhereIsInLowerTyped: createWhereIsInLowerTypedMethod('orWhere'),
57
55
  },
58
56
  };
59
- const queryBuilders = [
60
- typeorm_1.SelectQueryBuilder,
61
- typeorm_1.UpdateQueryBuilder,
62
- typeorm_1.DeleteQueryBuilder,
63
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
64
- ];
65
- queryBuilders.forEach((builder) => {
66
- (0, prototype_utils_1.patchPrototype)(builder, extension);
67
- });
57
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
68
58
  // implementation
69
59
  const lower = (sql) => `LOWER(${sql})`;
70
60
  /**
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const typeorm_1 = require("typeorm");
4
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
5
4
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
5
  const prototype_utils_1 = require("../../../utils/prototype.utils");
7
6
  const sql_utils_1 = require("../../../utils/sql.utils");
@@ -63,13 +62,5 @@ const scoreExtension = {
63
62
  },
64
63
  },
65
64
  };
66
- const queryBuilders = [
67
- typeorm_1.SelectQueryBuilder,
68
- typeorm_1.UpdateQueryBuilder,
69
- typeorm_1.DeleteQueryBuilder,
70
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
71
- ];
72
- queryBuilders.forEach((builder) => {
73
- (0, prototype_utils_1.patchPrototype)(builder, extension);
74
- });
65
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
75
66
  (0, prototype_utils_1.patchPrototype)(typeorm_1.SelectQueryBuilder, scoreExtension);
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
5
3
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
7
5
  const where_utils_1 = require("../../../utils/where.utils");
@@ -17,22 +15,14 @@ const extension = {
17
15
  orWhereTyped: createWhereTypedMethod('orWhere'),
18
16
  },
19
17
  };
20
- const queryBuilders = [
21
- typeorm_1.SelectQueryBuilder,
22
- typeorm_1.UpdateQueryBuilder,
23
- typeorm_1.DeleteQueryBuilder,
24
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
25
- ];
26
- queryBuilders.forEach((builder) => {
27
- (0, prototype_utils_1.patchPrototype)(builder, extension);
28
- });
18
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
29
19
  // implementation
30
20
  function attachTypedWhere(builder, method, where, conditions, parameters, options) {
31
21
  const { addValue } = options || {};
32
22
  if (typeof where === 'function') {
33
23
  // several columns have no single meaning (AND? OR?), and `where…` kept only the last one
34
24
  // a path into a JSON column is cast to the type of the value it is compared with
35
- const value = (0, where_utils_1.isParamsObject)(parameters) ? Object.values(parameters)[0] : parameters;
25
+ const value = (0, where_utils_1.getComparedValue)(parameters);
36
26
  const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value });
37
27
  return (0, where_utils_1.attachWhere)(builder, method, key, conditions, parameters, {
38
28
  addValue,
@@ -46,7 +46,7 @@ function ordersOrLimits(query, sql) {
46
46
  return Object.keys(allOrderBys !== null && allOrderBys !== void 0 ? allOrderBys : {}).length > 0 || [limit, offset, take, skip].some((value) => value !== undefined);
47
47
  }
48
48
  function bindParameters(builder, query) {
49
- const [sql, parameters] = (0, parameter_utils_1.withUniqueParameterNames)(query.getQuery(), query.getParameters());
49
+ const [sql, parameters] = (0, parameter_utils_1.toSubQuerySql)(query);
50
50
  builder.setParameters(parameters);
51
51
  return sql;
52
52
  }
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
5
3
  const prototype_utils_1 = require("../utils/prototype.utils");
6
4
  const query_builder_utils_1 = require("../utils/query-builder.utils");
7
5
  const sql_utils_1 = require("../utils/sql.utils");
@@ -21,15 +19,7 @@ const extension = {
21
19
  orWhereArrayOverlaps: createWhereArrayMethod('orWhere', '&&'),
22
20
  },
23
21
  };
24
- const queryBuilders = [
25
- typeorm_1.SelectQueryBuilder,
26
- typeorm_1.UpdateQueryBuilder,
27
- typeorm_1.DeleteQueryBuilder,
28
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
29
- ];
30
- queryBuilders.forEach((builder) => {
31
- (0, prototype_utils_1.patchPrototype)(builder, extension);
32
- });
22
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
33
23
  // implementation
34
24
  function attachWhereArray(builder, method, field, operator, values, arrayType) {
35
25
  if (!method || typeof field !== 'string') {
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.attachExists = void 0;
4
- const typeorm_1 = require("typeorm");
5
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
6
4
  const prototype_utils_1 = require("../utils/prototype.utils");
7
5
  const parameter_utils_1 = require("../utils/parameter.utils");
6
+ const query_builder_utils_1 = require("../utils/query-builder.utils");
8
7
  const existsMethods = {
9
8
  prototype: {
10
9
  whereExists(subQuery) {
@@ -33,10 +32,8 @@ const notExistsMethods = {
33
32
  };
34
33
  // only where the builder lacks them: SelectQueryBuilder keeps TypeORM's own whereExists /
35
34
  // andWhereExists / orWhereExists, and a later TypeORM that adds any of these keeps its own
36
- [typeorm_1.SelectQueryBuilder, typeorm_1.UpdateQueryBuilder, typeorm_1.DeleteQueryBuilder, SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder].forEach((builder) => {
37
- (0, prototype_utils_1.patchPrototype)(builder, existsMethods, { onlyMissing: true });
38
- (0, prototype_utils_1.patchPrototype)(builder, notExistsMethods, { onlyMissing: true });
39
- });
35
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, existsMethods, { onlyMissing: true });
36
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, notExistsMethods, { onlyMissing: true });
40
37
  // implementation
41
38
  function attachExists(builder, method, subQuery, negate) {
42
39
  const [condition, parameters] = (0, parameter_utils_1.withUniqueParameterNames)(...getExistsCondition(subQuery));
@@ -48,15 +45,7 @@ exports.attachExists = attachExists;
48
45
  * drops GROUP BY, which leaves a HAVING to aggregate the whole subquery: the GROUP BY stays with one.
49
46
  */
50
47
  function getExistsCondition(subQuery) {
51
- const query = subQuery
52
- .clone()
53
- .orderBy()
54
- .offset(undefined)
55
- .limit(undefined)
56
- .skip(undefined)
57
- .take(undefined)
58
- .select('1')
59
- .setOption('disable-global-order');
48
+ const query = (0, query_builder_utils_1.withoutPaging)(subQuery.clone()).select('1');
60
49
  if (query.expressionMap.havings.length === 0) {
61
50
  query.groupBy();
62
51
  }
@@ -1,177 +1,55 @@
1
1
  import { ObjectLiteral } from 'typeorm';
2
2
  import { ArgsType } from '../types/util-types';
3
+ export interface WhereIsAnyMethods {
4
+ /**
5
+ * Sets WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
6
+ * The array is bound as a single parameter instead of one parameter per value.
7
+ * `arrayType` (e.g. `'uuid[]'`) casts the parameter: `= ANY(CAST(:array AS uuid[]))`.
8
+ * If you had previously WHERE expression defined,
9
+ * calling this function will override previously set WHERE conditions.
10
+ */
11
+ whereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
12
+ /**
13
+ * Adds new AND WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
14
+ */
15
+ andWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
16
+ /**
17
+ * Adds new OR WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
18
+ */
19
+ orWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
20
+ /**
21
+ * Sets WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL):
22
+ * the field differs from every value of the array.
23
+ * If you had previously WHERE expression defined,
24
+ * calling this function will override previously set WHERE conditions.
25
+ */
26
+ whereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
27
+ /**
28
+ * Adds new AND WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
29
+ */
30
+ andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
31
+ /**
32
+ * Adds new OR WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
33
+ */
34
+ orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
35
+ }
3
36
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
4
- interface WhereExpressionBuilder {
5
- /**
6
- * Sets WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
7
- * The array is bound as a single parameter instead of one parameter per value.
8
- * `arrayType` (e.g. `'uuid[]'`) casts the parameter: `= ANY(CAST(:array AS uuid[]))`.
9
- * If you had previously WHERE expression defined,
10
- * calling this function will override previously set WHERE conditions.
11
- */
12
- whereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
13
- /**
14
- * Adds new AND WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
15
- */
16
- andWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
17
- /**
18
- * Adds new OR WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
19
- */
20
- orWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
21
- /**
22
- * Sets WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL):
23
- * the field differs from every value of the array.
24
- * If you had previously WHERE expression defined,
25
- * calling this function will override previously set WHERE conditions.
26
- */
27
- whereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
28
- /**
29
- * Adds new AND WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
30
- */
31
- andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
32
- /**
33
- * Adds new OR WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
34
- */
35
- orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
37
+ interface WhereExpressionBuilder extends WhereIsAnyMethods {
36
38
  }
37
39
  }
38
40
  declare module 'typeorm/query-builder/SelectQueryBuilder' {
39
- interface SelectQueryBuilder<Entity extends ObjectLiteral> {
40
- /**
41
- * Sets WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
42
- * The array is bound as a single parameter instead of one parameter per value.
43
- * `arrayType` (e.g. `'uuid[]'`) casts the parameter: `= ANY(CAST(:array AS uuid[]))`.
44
- * If you had previously WHERE expression defined,
45
- * calling this function will override previously set WHERE conditions.
46
- */
47
- whereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
48
- /**
49
- * Adds new AND WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
50
- */
51
- andWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
52
- /**
53
- * Adds new OR WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
54
- */
55
- orWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
56
- /**
57
- * Sets WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL):
58
- * the field differs from every value of the array.
59
- * If you had previously WHERE expression defined,
60
- * calling this function will override previously set WHERE conditions.
61
- */
62
- whereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
63
- /**
64
- * Adds new AND WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
65
- */
66
- andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
67
- /**
68
- * Adds new OR WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
69
- */
70
- orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
41
+ interface SelectQueryBuilder<Entity extends ObjectLiteral> extends WhereIsAnyMethods {
71
42
  }
72
43
  }
73
44
  declare module 'typeorm/query-builder/UpdateQueryBuilder' {
74
- interface UpdateQueryBuilder<Entity extends ObjectLiteral> {
75
- /**
76
- * Sets WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
77
- * The array is bound as a single parameter instead of one parameter per value.
78
- * `arrayType` (e.g. `'uuid[]'`) casts the parameter: `= ANY(CAST(:array AS uuid[]))`.
79
- * If you had previously WHERE expression defined,
80
- * calling this function will override previously set WHERE conditions.
81
- */
82
- whereIsAny(field: string, array?: ArgsType, arrayType?: string): UpdateQueryBuilder<Entity>;
83
- /**
84
- * Adds new AND WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
85
- */
86
- andWhereIsAny(field: string, array?: ArgsType, arrayType?: string): UpdateQueryBuilder<Entity>;
87
- /**
88
- * Adds new OR WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
89
- */
90
- orWhereIsAny(field: string, array?: ArgsType, arrayType?: string): UpdateQueryBuilder<Entity>;
91
- /**
92
- * Sets WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL):
93
- * the field differs from every value of the array.
94
- * If you had previously WHERE expression defined,
95
- * calling this function will override previously set WHERE conditions.
96
- */
97
- whereIsNotAny(field: string, array?: ArgsType, arrayType?: string): UpdateQueryBuilder<Entity>;
98
- /**
99
- * Adds new AND WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
100
- */
101
- andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): UpdateQueryBuilder<Entity>;
102
- /**
103
- * Adds new OR WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
104
- */
105
- orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): UpdateQueryBuilder<Entity>;
45
+ interface UpdateQueryBuilder<Entity extends ObjectLiteral> extends WhereIsAnyMethods {
106
46
  }
107
47
  }
108
48
  declare module 'typeorm/query-builder/DeleteQueryBuilder' {
109
- interface DeleteQueryBuilder<Entity extends ObjectLiteral> {
110
- /**
111
- * Sets WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
112
- * The array is bound as a single parameter instead of one parameter per value.
113
- * `arrayType` (e.g. `'uuid[]'`) casts the parameter: `= ANY(CAST(:array AS uuid[]))`.
114
- * If you had previously WHERE expression defined,
115
- * calling this function will override previously set WHERE conditions.
116
- */
117
- whereIsAny(field: string, array?: ArgsType, arrayType?: string): DeleteQueryBuilder<Entity>;
118
- /**
119
- * Adds new AND WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
120
- */
121
- andWhereIsAny(field: string, array?: ArgsType, arrayType?: string): DeleteQueryBuilder<Entity>;
122
- /**
123
- * Adds new OR WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
124
- */
125
- orWhereIsAny(field: string, array?: ArgsType, arrayType?: string): DeleteQueryBuilder<Entity>;
126
- /**
127
- * Sets WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL):
128
- * the field differs from every value of the array.
129
- * If you had previously WHERE expression defined,
130
- * calling this function will override previously set WHERE conditions.
131
- */
132
- whereIsNotAny(field: string, array?: ArgsType, arrayType?: string): DeleteQueryBuilder<Entity>;
133
- /**
134
- * Adds new AND WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
135
- */
136
- andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): DeleteQueryBuilder<Entity>;
137
- /**
138
- * Adds new OR WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
139
- */
140
- orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): DeleteQueryBuilder<Entity>;
49
+ interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereIsAnyMethods {
141
50
  }
142
51
  }
143
52
  declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
144
- interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> {
145
- /**
146
- * Sets WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
147
- * The array is bound as a single parameter instead of one parameter per value.
148
- * `arrayType` (e.g. `'uuid[]'`) casts the parameter: `= ANY(CAST(:array AS uuid[]))`.
149
- * If you had previously WHERE expression defined,
150
- * calling this function will override previously set WHERE conditions.
151
- */
152
- whereIsAny(field: string, array?: ArgsType, arrayType?: string): SoftDeleteQueryBuilder<Entity>;
153
- /**
154
- * Adds new AND WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
155
- */
156
- andWhereIsAny(field: string, array?: ArgsType, arrayType?: string): SoftDeleteQueryBuilder<Entity>;
157
- /**
158
- * Adds new OR WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
159
- */
160
- orWhereIsAny(field: string, array?: ArgsType, arrayType?: string): SoftDeleteQueryBuilder<Entity>;
161
- /**
162
- * Sets WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL):
163
- * the field differs from every value of the array.
164
- * If you had previously WHERE expression defined,
165
- * calling this function will override previously set WHERE conditions.
166
- */
167
- whereIsNotAny(field: string, array?: ArgsType, arrayType?: string): SoftDeleteQueryBuilder<Entity>;
168
- /**
169
- * Adds new AND WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
170
- */
171
- andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): SoftDeleteQueryBuilder<Entity>;
172
- /**
173
- * Adds new OR WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
174
- */
175
- orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): SoftDeleteQueryBuilder<Entity>;
53
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereIsAnyMethods {
176
54
  }
177
55
  }
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
5
3
  const prototype_utils_1 = require("../utils/prototype.utils");
6
4
  const query_builder_utils_1 = require("../utils/query-builder.utils");
7
5
  const sql_utils_1 = require("../utils/sql.utils");
@@ -18,15 +16,7 @@ const extension = {
18
16
  orWhereIsNotAny: createWhereIsAnyMethod('orWhere', '<> ALL'),
19
17
  },
20
18
  };
21
- const queryBuilders = [
22
- typeorm_1.SelectQueryBuilder,
23
- typeorm_1.UpdateQueryBuilder,
24
- typeorm_1.DeleteQueryBuilder,
25
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
19
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
30
20
  // implementation
31
21
  function attachWhereIsAny(builder, method, field, comparison, array, arrayType) {
32
22
  if (!method || typeof field !== 'string') {
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
- const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
5
3
  const prototype_utils_1 = require("../utils/prototype.utils");
6
4
  const query_builder_utils_1 = require("../utils/query-builder.utils");
7
5
  const sql_utils_1 = require("../utils/sql.utils");
@@ -20,15 +18,7 @@ const extension = {
20
18
  orWhereIsNotDistinctFrom: createWhereDistinctMethod('orWhere', false),
21
19
  },
22
20
  };
23
- const queryBuilders = [
24
- typeorm_1.SelectQueryBuilder,
25
- typeorm_1.UpdateQueryBuilder,
26
- typeorm_1.DeleteQueryBuilder,
27
- SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
28
- ];
29
- queryBuilders.forEach((builder) => {
30
- (0, prototype_utils_1.patchPrototype)(builder, extension);
31
- });
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
32
22
  // implementation
33
23
  /** `field IS [NOT] DISTINCT FROM value` in the database's own null-safe syntax. */
34
24
  function buildDistinctCondition(driver, field, distinct, value) {