typeorm-extensions 2.2.0-rc.1 → 2.2.0-rc.10

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 (112) hide show
  1. package/README.md +70 -39
  2. package/dist/decorators/calculated-column.decorator.d.ts +7 -3
  3. package/dist/decorators/calculated-column.decorator.js +35 -6
  4. package/dist/decorators/generated-column.decorator.d.ts +17 -0
  5. package/dist/decorators/generated-column.decorator.js +15 -0
  6. package/dist/decorators/index.d.ts +1 -0
  7. package/dist/decorators/index.js +1 -0
  8. package/dist/extensions/calculated-column.extension.d.ts +3 -3
  9. package/dist/extensions/calculated-column.extension.js +3 -16
  10. package/dist/extensions/cursor-pagination.extension.d.ts +2 -1
  11. package/dist/extensions/cursor-pagination.extension.js +7 -13
  12. package/dist/extensions/get-many-with-totals.extension.js +10 -29
  13. package/dist/extensions/join-lateral.extension.js +4 -6
  14. package/dist/extensions/order.extension.d.ts +2 -2
  15. package/dist/extensions/pagination.extension.d.ts +1 -1
  16. package/dist/extensions/period-filter.extension.d.ts +4 -0
  17. package/dist/extensions/period-filter.extension.js +1 -9
  18. package/dist/extensions/typed/index.d.ts +2 -0
  19. package/dist/extensions/typed/index.js +2 -0
  20. package/dist/extensions/typed/typed-calculated/typed-calculated-column.extension.d.ts +19 -0
  21. package/dist/extensions/typed/typed-calculated/typed-calculated-column.extension.js +17 -0
  22. package/dist/extensions/typed/typed-distinct/typed-distinct.extension.d.ts +6 -4
  23. package/dist/extensions/typed/typed-distinct/typed-distinct.extension.js +9 -2
  24. package/dist/extensions/typed/typed-group-by/typed-group-by.extension.d.ts +8 -7
  25. package/dist/extensions/typed/typed-group-by/typed-group-by.extension.js +1 -1
  26. package/dist/extensions/typed/typed-having/typed-having.extension.d.ts +4 -4
  27. package/dist/extensions/typed/typed-having/typed-having.extension.js +1 -1
  28. package/dist/extensions/typed/typed-joins/typed-join-and-map.extension.d.ts +19 -0
  29. package/dist/extensions/typed/typed-joins/typed-join-and-map.extension.js +23 -0
  30. package/dist/extensions/typed/typed-joins/typed-joins.extension.d.ts +4 -4
  31. package/dist/extensions/typed/typed-joins/typed-joins.extension.js +11 -22
  32. package/dist/extensions/typed/typed-order-by/typed-order-by-array-position.extension.d.ts +2 -2
  33. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.d.ts +4 -2
  34. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.js +18 -17
  35. package/dist/extensions/typed/typed-returning/typed-returning.extension.js +1 -9
  36. package/dist/extensions/typed/typed-root.extension.d.ts +26 -4
  37. package/dist/extensions/typed/typed-select/typed-select.extension.d.ts +6 -6
  38. package/dist/extensions/typed/typed-select/typed-select.extension.js +3 -9
  39. package/dist/extensions/typed/typed-where/typed-period-filter.extension.d.ts +5 -1
  40. package/dist/extensions/typed/typed-where/typed-period-filter.extension.js +1 -9
  41. package/dist/extensions/typed/typed-where/typed-where-array.extension.d.ts +13 -9
  42. package/dist/extensions/typed/typed-where/typed-where-array.extension.js +4 -16
  43. package/dist/extensions/typed/typed-where/typed-where-ilike.extension.d.ts +10 -6
  44. package/dist/extensions/typed/typed-where/typed-where-ilike.extension.js +1 -9
  45. package/dist/extensions/typed/typed-where/typed-where-is-any.extension.d.ts +10 -6
  46. package/dist/extensions/typed/typed-where/typed-where-is-any.extension.js +3 -20
  47. package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.d.ts +10 -6
  48. package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.js +3 -20
  49. package/dist/extensions/typed/typed-where/typed-where-is-in.extension.d.ts +10 -6
  50. package/dist/extensions/typed/typed-where/typed-where-is-in.extension.js +3 -21
  51. package/dist/extensions/typed/typed-where/typed-where-json.extension.d.ts +10 -6
  52. package/dist/extensions/typed/typed-where/typed-where-json.extension.js +4 -21
  53. package/dist/extensions/typed/typed-where/typed-where-lower.extension.d.ts +10 -6
  54. package/dist/extensions/typed/typed-where/typed-where-lower.extension.js +1 -9
  55. package/dist/extensions/typed/typed-where/typed-where-similar.extension.d.ts +8 -4
  56. package/dist/extensions/typed/typed-where/typed-where-similar.extension.js +1 -8
  57. package/dist/extensions/typed/typed-where/typed-where.extension.d.ts +7 -3
  58. package/dist/extensions/typed/typed-where/typed-where.extension.js +2 -10
  59. package/dist/extensions/union.extension.js +1 -1
  60. package/dist/extensions/where-array.extension.d.ts +4 -0
  61. package/dist/extensions/where-array.extension.js +1 -9
  62. package/dist/extensions/where-exists.extension.js +4 -15
  63. package/dist/extensions/where-is-any.extension.d.ts +41 -128
  64. package/dist/extensions/where-is-any.extension.js +1 -9
  65. package/dist/extensions/where-is-distinct-from.extension.d.ts +4 -0
  66. package/dist/extensions/where-is-distinct-from.extension.js +1 -9
  67. package/dist/extensions/where-is-in.extension.d.ts +38 -116
  68. package/dist/extensions/where-is-in.extension.js +11 -27
  69. package/dist/extensions/where-json.extension.d.ts +4 -0
  70. package/dist/extensions/where-json.extension.js +1 -9
  71. package/dist/extensions/where-relation-exists.extension.d.ts +6 -6
  72. package/dist/extensions/where-relation-exists.extension.js +5 -25
  73. package/dist/helpers.d.ts +5 -0
  74. package/dist/helpers.js +12 -3
  75. package/dist/index.d.ts +1 -2
  76. package/dist/index.js +1 -4
  77. package/dist/types/extensions/cursor-pagination.types.d.ts +5 -0
  78. package/dist/types/extensions/get-many-with-totals.types.d.ts +4 -0
  79. package/dist/types/extensions/index.d.ts +1 -0
  80. package/dist/types/extensions/index.js +1 -0
  81. package/dist/types/extensions/typed-group-by.types.d.ts +2 -2
  82. package/dist/types/extensions/typed-join-and-map.types.d.ts +6 -0
  83. package/dist/types/extensions/typed-join-and-map.types.js +2 -0
  84. package/dist/types/modules/typed-root.types.d.ts +11 -9
  85. package/dist/utils/calculated-column.utils.d.ts +11 -0
  86. package/dist/utils/calculated-column.utils.js +33 -4
  87. package/dist/utils/common.utils.d.ts +2 -0
  88. package/dist/utils/common.utils.js +4 -1
  89. package/dist/utils/cursor.utils.js +4 -6
  90. package/dist/utils/json-path.utils.js +2 -2
  91. package/dist/utils/pagination.utils.d.ts +7 -0
  92. package/dist/utils/pagination.utils.js +20 -10
  93. package/dist/utils/parameter.utils.d.ts +10 -0
  94. package/dist/utils/parameter.utils.js +22 -1
  95. package/dist/utils/period.utils.js +2 -1
  96. package/dist/utils/prototype.utils.d.ts +9 -0
  97. package/dist/utils/prototype.utils.js +12 -2
  98. package/dist/utils/query-builder.utils.d.ts +43 -4
  99. package/dist/utils/query-builder.utils.js +239 -36
  100. package/dist/utils/reserved-qualifier-guard.utils.d.ts +36 -0
  101. package/dist/utils/reserved-qualifier-guard.utils.js +98 -0
  102. package/dist/utils/reserved-qualifier.utils.d.ts +33 -0
  103. package/dist/utils/reserved-qualifier.utils.js +252 -0
  104. package/dist/utils/table.utils.d.ts +27 -11
  105. package/dist/utils/table.utils.js +58 -23
  106. package/dist/utils/time-zone.utils.d.ts +8 -0
  107. package/dist/utils/time-zone.utils.js +15 -5
  108. package/dist/utils/typed-where.utils.d.ts +9 -0
  109. package/dist/utils/typed-where.utils.js +17 -0
  110. package/dist/utils/where.utils.d.ts +2 -0
  111. package/dist/utils/where.utils.js +21 -14
  112. package/package.json +2 -2
@@ -14,17 +14,17 @@ export interface TypedWhereILikeMethods<Entity extends ObjectLiteral> {
14
14
  * If you had previously WHERE expression defined,
15
15
  * calling this function will override previously set WHERE conditions.
16
16
  */
17
- whereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
17
+ whereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
18
18
  /**
19
19
  * Adds new AND WHERE `column ILIKE :pattern` condition in the query builder.
20
20
  * `null`, `undefined` or a blank value adds no condition.
21
21
  */
22
- andWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
22
+ andWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
23
23
  /**
24
24
  * Adds new OR WHERE `column ILIKE :pattern` condition in the query builder.
25
25
  * `null`, `undefined` or a blank value adds no condition.
26
26
  */
27
- orWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
27
+ orWhereILikeTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedILikeOptions): this;
28
28
  /**
29
29
  * Sets WHERE `(col1 ILIKE :pattern OR col2 ILIKE :pattern …)` condition in the query builder:
30
30
  * one group, one parameter for every column. A selector is a typed callback (it may select
@@ -33,17 +33,17 @@ export interface TypedWhereILikeMethods<Entity extends ObjectLiteral> {
33
33
  * If you had previously WHERE expression defined,
34
34
  * calling this function will override previously set WHERE conditions.
35
35
  */
36
- whereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
36
+ whereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
37
37
  /**
38
38
  * Adds new AND WHERE `(col1 ILIKE :pattern OR col2 ILIKE :pattern …)` condition in the query builder.
39
39
  * A value shorter than `options.minLength` (default 1, after trimming) adds no condition.
40
40
  */
41
- andWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
41
+ andWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
42
42
  /**
43
43
  * Adds new OR WHERE `(col1 ILIKE :pattern OR col2 ILIKE :pattern …)` condition in the query builder.
44
44
  * A value shorter than `options.minLength` (default 1, after trimming) adds no condition.
45
45
  */
46
- orWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
46
+ orWhereSearchTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selectors: ReadonlyArray<SearchSelector<Type>>, value: string | null | undefined, options?: TypedSearchOptions): this;
47
47
  }
48
48
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
49
49
  interface WhereExpressionBuilder extends TypedWhereILikeMethods<ObjectLiteral> {
@@ -61,3 +61,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
61
61
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereILikeMethods<Entity> {
62
62
  }
63
63
  }
64
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
65
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereILikeMethods<Entity> {
66
+ }
67
+ }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
3
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
5
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
6
5
  const sql_utils_1 = require("../../../utils/sql.utils");
@@ -42,14 +41,7 @@ const extension = {
42
41
  orWhereSearchTyped: createWhereSearchTypedMethod('orWhere'),
43
42
  },
44
43
  };
45
- const queryBuilders = [
46
- typeorm_1.SelectQueryBuilder,
47
- typeorm_1.UpdateQueryBuilder,
48
- typeorm_1.DeleteQueryBuilder,
49
- ];
50
- queryBuilders.forEach((builder) => {
51
- (0, prototype_utils_1.patchPrototype)(builder, extension);
52
- });
44
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
53
45
  // implementation
54
46
  /** Quoted columns and raw expressions of the search selectors, in order. */
55
47
  function getSearchColumns(builder, selectors, methodName) {
@@ -11,30 +11,30 @@ export interface TypedWhereIsAnyMethods<Entity extends ObjectLiteral> {
11
11
  * If you had previously WHERE expression defined,
12
12
  * calling this function will override previously set WHERE conditions.
13
13
  */
14
- whereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
14
+ whereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
15
15
  /**
16
16
  * Adds new AND WHERE `column = ANY(:array)` condition in the query builder (PostgreSQL).
17
17
  */
18
- andWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
18
+ andWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
19
19
  /**
20
20
  * Adds new OR WHERE `column = ANY(:array)` condition in the query builder (PostgreSQL).
21
21
  */
22
- orWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
22
+ orWhereIsAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
23
23
  /**
24
24
  * Sets WHERE `column <> ALL(:array)` condition in the query builder (PostgreSQL):
25
25
  * the column differs from every value of the array.
26
26
  * If you had previously WHERE expression defined,
27
27
  * calling this function will override previously set WHERE conditions.
28
28
  */
29
- whereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
29
+ whereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
30
30
  /**
31
31
  * Adds new AND WHERE `column <> ALL(:array)` condition in the query builder (PostgreSQL).
32
32
  */
33
- andWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
33
+ andWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
34
34
  /**
35
35
  * Adds new OR WHERE `column <> ALL(:array)` condition in the query builder (PostgreSQL).
36
36
  */
37
- orWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
37
+ orWhereIsNotAnyTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>, arrayType?: string): this;
38
38
  }
39
39
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
40
40
  interface WhereExpressionBuilder extends TypedWhereIsAnyMethods<ObjectLiteral> {
@@ -52,3 +52,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
52
52
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsAnyMethods<Entity> {
53
53
  }
54
54
  }
55
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
56
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsAnyMethods<Entity> {
57
+ }
58
+ }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-is-any.extension");
4
- const typeorm_1 = require("typeorm");
5
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereIsAnyTypedMethod = (method) => function (where, array, arrayType) {
10
- return attachWhereIsAnyTyped(this, method, where, array, arrayType);
9
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { value: array }, array, arrayType);
11
10
  };
12
11
  const extension = {
13
12
  prototype: {
@@ -19,20 +18,4 @@ const extension = {
19
18
  orWhereIsNotAnyTyped: createWhereIsAnyTypedMethod('orWhereIsNotAny'),
20
19
  },
21
20
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereIsAnyTyped(builder, method, where, array, arrayType) {
32
- if (typeof where !== 'function') {
33
- return builder;
34
- }
35
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value: array });
36
- // .andWhere(`"table"."column" = ANY(:param)`, { param: ['value'] })
37
- return builder[method](key, array, arrayType);
38
- }
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -12,29 +12,29 @@ export interface TypedWhereDistinctMethods<Entity extends ObjectLiteral> {
12
12
  * If you had previously WHERE expression defined,
13
13
  * calling this function will override previously set WHERE conditions.
14
14
  */
15
- whereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
15
+ whereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
16
16
  /**
17
17
  * Adds new AND WHERE `column IS DISTINCT FROM :value` condition: the column differs from the value, `NULL` included.
18
18
  */
19
- andWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
19
+ andWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
20
20
  /**
21
21
  * Adds new OR WHERE `column IS DISTINCT FROM :value` condition: the column differs from the value, `NULL` included.
22
22
  */
23
- orWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
23
+ orWhereIsDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
24
24
  /**
25
25
  * Sets WHERE `column IS NOT DISTINCT FROM :value` condition: the column equals the value, `NULL` included.
26
26
  * If you had previously WHERE expression defined,
27
27
  * calling this function will override previously set WHERE conditions.
28
28
  */
29
- whereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
29
+ whereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
30
30
  /**
31
31
  * Adds new AND WHERE `column IS NOT DISTINCT FROM :value` condition: the column equals the value, `NULL` included.
32
32
  */
33
- andWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
33
+ andWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
34
34
  /**
35
35
  * Adds new OR WHERE `column IS NOT DISTINCT FROM :value` condition: the column equals the value, `NULL` included.
36
36
  */
37
- orWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
37
+ orWhereIsNotDistinctFromTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
38
38
  }
39
39
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
40
40
  interface WhereExpressionBuilder extends TypedWhereDistinctMethods<ObjectLiteral> {
@@ -52,3 +52,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
52
52
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereDistinctMethods<Entity> {
53
53
  }
54
54
  }
55
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
56
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereDistinctMethods<Entity> {
57
+ }
58
+ }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../where-is-distinct-from.extension");
4
- const typeorm_1 = require("typeorm");
5
- const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereDistinctTypedMethod = (method) => function (where, value) {
10
- return attachWhereDistinctTyped(this, method, where, value);
9
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { value }, value);
11
10
  };
12
11
  const extension = {
13
12
  prototype: {
@@ -19,20 +18,4 @@ const extension = {
19
18
  orWhereIsNotDistinctFromTyped: createWhereDistinctTypedMethod('orWhereIsNotDistinctFrom'),
20
19
  },
21
20
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereDistinctTyped(builder, method, where, value) {
32
- if (typeof where !== 'function') {
33
- return builder;
34
- }
35
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value });
36
- // .andWhereIsDistinctFrom(`"table"."column"`, value)
37
- return builder[method](key, value);
38
- }
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -9,29 +9,29 @@ export interface TypedWhereIsInMethods<Entity extends ObjectLiteral> {
9
9
  * If you had previously WHERE expression defined,
10
10
  * calling this function will override previously set WHERE conditions.
11
11
  */
12
- whereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
12
+ whereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
13
13
  /**
14
14
  * Adds new AND WHERE IN condition in the query builder.
15
15
  */
16
- andWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
16
+ andWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
17
17
  /**
18
18
  * Adds new OR WHERE IN condition in the query builder.
19
19
  */
20
- orWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
20
+ orWhereIsInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
21
21
  /**
22
22
  * Sets WHERE NOT IN condition in the query builder.
23
23
  * If you had previously WHERE expression defined,
24
24
  * calling this function will override previously set WHERE conditions.
25
25
  */
26
- whereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
26
+ whereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
27
27
  /**
28
28
  * Adds new AND WHERE NOT IN condition in the query builder.
29
29
  */
30
- andWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
30
+ andWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
31
31
  /**
32
32
  * Adds new OR WHERE NOT IN condition in the query builder.
33
33
  */
34
- orWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
34
+ orWhereIsNotInTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, array?: TypedArrayArg<Type, Value>): this;
35
35
  }
36
36
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
37
37
  interface WhereExpressionBuilder extends TypedWhereIsInMethods<ObjectLiteral> {
@@ -49,3 +49,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
49
49
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsInMethods<Entity> {
50
50
  }
51
51
  }
52
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
53
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereIsInMethods<Entity> {
54
+ }
55
+ }
@@ -1,13 +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 query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereIsInTypedMethod = (method) => function (where, array) {
10
- return attachWhereIsIn(this, method, where, array);
9
+ return (0, typed_where_utils_1.attachTypedColumnWhere)(this, method, where, { value: array }, array);
11
10
  };
12
11
  const extension = {
13
12
  prototype: {
@@ -19,21 +18,4 @@ const extension = {
19
18
  orWhereIsNotInTyped: createWhereIsInTypedMethod('orWhereIsNotIn'),
20
19
  },
21
20
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereIsIn(builder, method, where, array) {
32
- if (typeof where === 'function') {
33
- // several columns have no single meaning (AND? OR?), and `where…` kept only the last one
34
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value: array });
35
- // .andWhere(`"table"."column" IN (:...values)`, { values: ['value'] })
36
- return builder[method](key, array);
37
- }
38
- return builder;
39
- }
21
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -12,29 +12,29 @@ export interface TypedWhereJsonMethods<Entity extends ObjectLiteral> {
12
12
  * If you had previously WHERE expression defined,
13
13
  * calling this function will override previously set WHERE conditions.
14
14
  */
15
- whereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
15
+ whereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
16
16
  /**
17
17
  * Adds new AND WHERE `column @> :value` condition (PostgreSQL): the JSON document contains `value`.
18
18
  */
19
- andWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
19
+ andWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
20
20
  /**
21
21
  * Adds new OR WHERE `column @> :value` condition (PostgreSQL): the JSON document contains `value`.
22
22
  */
23
- orWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
23
+ orWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
24
24
  /**
25
25
  * Sets WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
26
26
  * If you had previously WHERE expression defined,
27
27
  * calling this function will override previously set WHERE conditions.
28
28
  */
29
- whereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
29
+ whereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
30
30
  /**
31
31
  * Adds new AND WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
32
32
  */
33
- andWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
33
+ andWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
34
34
  /**
35
35
  * Adds new OR WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
36
36
  */
37
- orWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
37
+ orWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
38
38
  }
39
39
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
40
40
  interface WhereExpressionBuilder extends TypedWhereJsonMethods<ObjectLiteral> {
@@ -52,3 +52,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
52
52
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereJsonMethods<Entity> {
53
53
  }
54
54
  }
55
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
56
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereJsonMethods<Entity> {
57
+ }
58
+ }
@@ -1,13 +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 query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
5
+ const typed_where_utils_1 = require("../../../utils/typed-where.utils");
7
6
  /* eslint-enable @typescript-eslint/no-empty-interface */
8
7
  // patching
9
8
  const createWhereJsonTypedMethod = (method) => function (where, value) {
10
- 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);
11
11
  };
12
12
  const extension = {
13
13
  prototype: {
@@ -19,21 +19,4 @@ const extension = {
19
19
  orWhereJsonHasKeyTyped: createWhereJsonTypedMethod('orWhereJsonHasKey'),
20
20
  },
21
21
  };
22
- const queryBuilders = [
23
- typeorm_1.SelectQueryBuilder,
24
- typeorm_1.UpdateQueryBuilder,
25
- typeorm_1.DeleteQueryBuilder,
26
- ];
27
- queryBuilders.forEach((builder) => {
28
- (0, prototype_utils_1.patchPrototype)(builder, extension);
29
- });
30
- // implementation
31
- function attachWhereJsonTyped(builder, method, where, value) {
32
- if (typeof where !== 'function') {
33
- return builder;
34
- }
35
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { accessor: 'json' });
36
- // .andWhereJsonContains(`"table"."column"`, { role: 'admin' }) / .andWhereJsonHasKey(`"table"."column"`, 'role')
37
- // (one signature for both: `value` is the JSON value or the key, each method checks its own)
38
- return builder[method](key, value);
39
- }
22
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
@@ -13,34 +13,34 @@ export interface TypedWhereLowerMethods<Entity extends ObjectLiteral> {
13
13
  * If you had previously WHERE expression defined,
14
14
  * calling this function will override previously set WHERE conditions.
15
15
  */
16
- whereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
16
+ whereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
17
17
  /**
18
18
  * Adds new AND WHERE `LOWER(column) = LOWER(:value)` condition in the query builder.
19
19
  * `null` / `undefined` matches nothing (`FALSE`).
20
20
  */
21
- andWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
21
+ andWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
22
22
  /**
23
23
  * Adds new OR WHERE `LOWER(column) = LOWER(:value)` condition in the query builder.
24
24
  * `null` / `undefined` matches nothing (`FALSE`).
25
25
  */
26
- orWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
26
+ orWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
27
27
  /**
28
28
  * Sets WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
29
29
  * An empty or missing array matches nothing (`FALSE`), like `whereIsIn`.
30
30
  * If you had previously WHERE expression defined,
31
31
  * calling this function will override previously set WHERE conditions.
32
32
  */
33
- whereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
33
+ whereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
34
34
  /**
35
35
  * Adds new AND WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
36
36
  * An empty or missing array matches nothing (`FALSE`).
37
37
  */
38
- andWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
38
+ andWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
39
39
  /**
40
40
  * Adds new OR WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
41
41
  * An empty or missing array matches nothing (`FALSE`).
42
42
  */
43
- orWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
43
+ orWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
44
44
  }
45
45
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
46
46
  interface WhereExpressionBuilder extends TypedWhereLowerMethods<ObjectLiteral> {
@@ -58,3 +58,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
58
58
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereLowerMethods<Entity> {
59
59
  }
60
60
  }
61
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
62
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereLowerMethods<Entity> {
63
+ }
64
+ }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
3
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
5
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
6
5
  const sql_utils_1 = require("../../../utils/sql.utils");
@@ -55,14 +54,7 @@ const extension = {
55
54
  orWhereIsInLowerTyped: createWhereIsInLowerTypedMethod('orWhere'),
56
55
  },
57
56
  };
58
- const queryBuilders = [
59
- typeorm_1.SelectQueryBuilder,
60
- typeorm_1.UpdateQueryBuilder,
61
- typeorm_1.DeleteQueryBuilder,
62
- ];
63
- queryBuilders.forEach((builder) => {
64
- (0, prototype_utils_1.patchPrototype)(builder, extension);
65
- });
57
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
66
58
  // implementation
67
59
  const lower = (sql) => `LOWER(${sql})`;
68
60
  /**
@@ -14,17 +14,17 @@ export interface TypedWhereSimilarMethods<Entity extends ObjectLiteral> {
14
14
  * If you had previously WHERE expression defined,
15
15
  * calling this function will override previously set WHERE conditions.
16
16
  */
17
- whereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
17
+ whereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
18
18
  /**
19
19
  * Adds new AND WHERE `column % :term` condition in the query builder (PostgreSQL, pg_trgm).
20
20
  * A blank term adds no condition.
21
21
  */
22
- andWhereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
22
+ andWhereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
23
23
  /**
24
24
  * Adds new OR WHERE `column % :term` condition in the query builder (PostgreSQL, pg_trgm).
25
25
  * A blank term adds no condition.
26
26
  */
27
- orWhereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
27
+ orWhereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
28
28
  }
29
29
  /** Trigram similarity score selection (PostgreSQL, `pg_trgm` extension). */
30
30
  export interface TypedSimilarityScoreMethods<Entity extends ObjectLiteral> {
@@ -35,7 +35,7 @@ export interface TypedSimilarityScoreMethods<Entity extends ObjectLiteral> {
35
35
  * (`word_similarity(:term, column)`, the score of `column %> :term`).
36
36
  * Use a lower-case alias: PostgreSQL folds an unquoted alias in ORDER BY.
37
37
  */
38
- addSimilarityScoreTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selection: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, alias: string, options?: SimilarityScoreOptions): this;
38
+ addSimilarityScoreTyped<Type extends ObjectLiteral = TypedRoot<Entity, this>>(selection: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, alias: string, options?: SimilarityScoreOptions): this;
39
39
  }
40
40
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
41
41
  interface WhereExpressionBuilder extends TypedWhereSimilarMethods<ObjectLiteral> {
@@ -53,3 +53,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
53
53
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereSimilarMethods<Entity> {
54
54
  }
55
55
  }
56
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
57
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereSimilarMethods<Entity> {
58
+ }
59
+ }
@@ -62,12 +62,5 @@ const scoreExtension = {
62
62
  },
63
63
  },
64
64
  };
65
- const queryBuilders = [
66
- typeorm_1.SelectQueryBuilder,
67
- typeorm_1.UpdateQueryBuilder,
68
- typeorm_1.DeleteQueryBuilder,
69
- ];
70
- queryBuilders.forEach((builder) => {
71
- (0, prototype_utils_1.patchPrototype)(builder, extension);
72
- });
65
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
73
66
  (0, prototype_utils_1.patchPrototype)(typeorm_1.SelectQueryBuilder, scoreExtension);
@@ -14,17 +14,17 @@ export interface TypedWhereMethods<Entity extends ObjectLiteral> {
14
14
  * calling this function will override previously set WHERE conditions.
15
15
  * Additionally you can add parameters used in where expression.
16
16
  */
17
- whereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
17
+ whereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
18
18
  /**
19
19
  * Adds new AND WHERE condition in the query builder.
20
20
  * Additionally you can add parameters used in where expression.
21
21
  */
22
- andWhereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
22
+ andWhereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
23
23
  /**
24
24
  * Adds new OR WHERE condition in the query builder.
25
25
  * Additionally you can add parameters used in where expression.
26
26
  */
27
- orWhereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
27
+ orWhereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity, this>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
28
28
  }
29
29
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
30
30
  interface WhereExpressionBuilder extends TypedWhereMethods<ObjectLiteral> {
@@ -42,3 +42,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
42
42
  interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereMethods<Entity> {
43
43
  }
44
44
  }
45
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
46
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereMethods<Entity> {
47
+ }
48
+ }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
3
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
5
4
  const prototype_utils_1 = require("../../../utils/prototype.utils");
6
5
  const where_utils_1 = require("../../../utils/where.utils");
@@ -16,21 +15,14 @@ const extension = {
16
15
  orWhereTyped: createWhereTypedMethod('orWhere'),
17
16
  },
18
17
  };
19
- const queryBuilders = [
20
- typeorm_1.SelectQueryBuilder,
21
- typeorm_1.UpdateQueryBuilder,
22
- typeorm_1.DeleteQueryBuilder,
23
- ];
24
- queryBuilders.forEach((builder) => {
25
- (0, prototype_utils_1.patchPrototype)(builder, extension);
26
- });
18
+ (0, prototype_utils_1.patchPrototypes)(prototype_utils_1.WHERE_QUERY_BUILDERS, extension);
27
19
  // implementation
28
20
  function attachTypedWhere(builder, method, where, conditions, parameters, options) {
29
21
  const { addValue } = options || {};
30
22
  if (typeof where === 'function') {
31
23
  // several columns have no single meaning (AND? OR?), and `where…` kept only the last one
32
24
  // a path into a JSON column is cast to the type of the value it is compared with
33
- const value = (0, where_utils_1.isParamsObject)(parameters) ? Object.values(parameters)[0] : parameters;
25
+ const value = (0, where_utils_1.getComparedValue)(parameters);
34
26
  const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value });
35
27
  return (0, where_utils_1.attachWhere)(builder, method, key, conditions, parameters, {
36
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
  }