typeorm-extensions 2.2.0-rc.6 → 2.2.0-rc.8
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.
- package/README.md +73 -34
- package/dist/decorators/generated-column.decorator.d.ts +17 -0
- package/dist/decorators/generated-column.decorator.js +15 -0
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +1 -0
- package/dist/extensions/cursor-pagination.extension.d.ts +2 -1
- package/dist/extensions/cursor-pagination.extension.js +4 -2
- package/dist/extensions/get-many-with-totals.extension.js +5 -12
- package/dist/extensions/order.extension.d.ts +2 -2
- package/dist/extensions/pagination.extension.d.ts +1 -1
- package/dist/extensions/period-filter.extension.d.ts +4 -0
- package/dist/extensions/period-filter.extension.js +2 -0
- package/dist/extensions/typed/index.d.ts +1 -0
- package/dist/extensions/typed/index.js +1 -0
- package/dist/extensions/typed/typed-distinct/typed-distinct.extension.d.ts +2 -2
- package/dist/extensions/typed/typed-group-by/typed-group-by.extension.d.ts +2 -2
- package/dist/extensions/typed/typed-having/typed-having.extension.d.ts +4 -4
- package/dist/extensions/typed/typed-joins/typed-join-and-map.extension.d.ts +19 -0
- package/dist/extensions/typed/typed-joins/typed-join-and-map.extension.js +22 -0
- package/dist/extensions/typed/typed-joins/typed-joins.extension.d.ts +4 -4
- package/dist/extensions/typed/typed-order-by/typed-order-by-array-position.extension.d.ts +2 -2
- package/dist/extensions/typed/typed-order-by/typed-order-by.extension.d.ts +2 -2
- package/dist/extensions/typed/typed-root.extension.d.ts +26 -4
- package/dist/extensions/typed/typed-select/typed-select.extension.d.ts +6 -6
- package/dist/extensions/typed/typed-where/typed-period-filter.extension.d.ts +5 -1
- package/dist/extensions/typed/typed-where/typed-period-filter.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-array.extension.d.ts +13 -9
- package/dist/extensions/typed/typed-where/typed-where-array.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-ilike.extension.d.ts +10 -6
- package/dist/extensions/typed/typed-where/typed-where-ilike.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-is-any.extension.d.ts +10 -6
- package/dist/extensions/typed/typed-where/typed-where-is-any.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.d.ts +10 -6
- package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-is-in.extension.d.ts +10 -6
- package/dist/extensions/typed/typed-where/typed-where-is-in.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-json.extension.d.ts +10 -6
- package/dist/extensions/typed/typed-where/typed-where-json.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-lower.extension.d.ts +10 -6
- package/dist/extensions/typed/typed-where/typed-where-lower.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where-similar.extension.d.ts +8 -4
- package/dist/extensions/typed/typed-where/typed-where-similar.extension.js +2 -0
- package/dist/extensions/typed/typed-where/typed-where.extension.d.ts +7 -3
- package/dist/extensions/typed/typed-where/typed-where.extension.js +2 -0
- package/dist/extensions/where-array.extension.d.ts +4 -0
- package/dist/extensions/where-array.extension.js +2 -0
- package/dist/extensions/where-is-any.extension.d.ts +41 -6
- package/dist/extensions/where-is-any.extension.js +2 -0
- package/dist/extensions/where-is-distinct-from.extension.d.ts +4 -0
- package/dist/extensions/where-is-distinct-from.extension.js +2 -0
- package/dist/extensions/where-is-in.extension.d.ts +38 -6
- package/dist/extensions/where-is-in.extension.js +2 -0
- package/dist/extensions/where-json.extension.d.ts +4 -0
- package/dist/extensions/where-json.extension.js +2 -0
- package/dist/extensions/where-relation-exists.extension.d.ts +6 -6
- package/dist/helpers.d.ts +5 -0
- package/dist/helpers.js +12 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -1
- package/dist/types/extensions/cursor-pagination.types.d.ts +5 -0
- package/dist/types/extensions/get-many-with-totals.types.d.ts +4 -0
- package/dist/types/extensions/index.d.ts +1 -0
- package/dist/types/extensions/index.js +1 -0
- package/dist/types/extensions/typed-join-and-map.types.d.ts +6 -0
- package/dist/types/extensions/typed-join-and-map.types.js +2 -0
- package/dist/types/modules/typed-root.types.d.ts +11 -9
- package/dist/utils/pagination.utils.d.ts +2 -0
- package/dist/utils/pagination.utils.js +1 -1
- package/dist/utils/query-builder.utils.d.ts +11 -2
- package/dist/utils/query-builder.utils.js +22 -5
- package/dist/utils/reserved-qualifier-guard.utils.d.ts +36 -0
- package/dist/utils/reserved-qualifier-guard.utils.js +98 -0
- package/dist/utils/reserved-qualifier.utils.d.ts +33 -0
- package/dist/utils/reserved-qualifier.utils.js +252 -0
- package/dist/utils/table.utils.d.ts +27 -11
- package/dist/utils/table.utils.js +49 -12
- package/package.json +2 -2
|
@@ -44,30 +44,30 @@ declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
|
44
44
|
* If you had previously WHERE expression defined,
|
|
45
45
|
* calling this function will override previously set WHERE conditions.
|
|
46
46
|
*/
|
|
47
|
-
whereIsAny(field: string, array?: ArgsType, arrayType?: string):
|
|
47
|
+
whereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
|
|
48
48
|
/**
|
|
49
49
|
* Adds new AND WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
|
|
50
50
|
*/
|
|
51
|
-
andWhereIsAny(field: string, array?: ArgsType, arrayType?: string):
|
|
51
|
+
andWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
|
|
52
52
|
/**
|
|
53
53
|
* Adds new OR WHERE `field = ANY(:array)` condition in the query builder (PostgreSQL).
|
|
54
54
|
*/
|
|
55
|
-
orWhereIsAny(field: string, array?: ArgsType, arrayType?: string):
|
|
55
|
+
orWhereIsAny(field: string, array?: ArgsType, arrayType?: string): this;
|
|
56
56
|
/**
|
|
57
57
|
* Sets WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL):
|
|
58
58
|
* the field differs from every value of the array.
|
|
59
59
|
* If you had previously WHERE expression defined,
|
|
60
60
|
* calling this function will override previously set WHERE conditions.
|
|
61
61
|
*/
|
|
62
|
-
whereIsNotAny(field: string, array?: ArgsType, arrayType?: string):
|
|
62
|
+
whereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
|
|
63
63
|
/**
|
|
64
64
|
* Adds new AND WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
|
|
65
65
|
*/
|
|
66
|
-
andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string):
|
|
66
|
+
andWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
|
|
67
67
|
/**
|
|
68
68
|
* Adds new OR WHERE `field <> ALL(:array)` condition in the query builder (PostgreSQL).
|
|
69
69
|
*/
|
|
70
|
-
orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string):
|
|
70
|
+
orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): this;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
declare module 'typeorm/query-builder/UpdateQueryBuilder' {
|
|
@@ -140,3 +140,38 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
|
|
|
140
140
|
orWhereIsNotAny(field: string, array?: ArgsType, arrayType?: string): DeleteQueryBuilder<Entity>;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
+
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>;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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");
|
|
4
5
|
const prototype_utils_1 = require("../utils/prototype.utils");
|
|
5
6
|
const query_builder_utils_1 = require("../utils/query-builder.utils");
|
|
6
7
|
const sql_utils_1 = require("../utils/sql.utils");
|
|
@@ -21,6 +22,7 @@ const queryBuilders = [
|
|
|
21
22
|
typeorm_1.SelectQueryBuilder,
|
|
22
23
|
typeorm_1.UpdateQueryBuilder,
|
|
23
24
|
typeorm_1.DeleteQueryBuilder,
|
|
25
|
+
SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
|
|
24
26
|
];
|
|
25
27
|
queryBuilders.forEach((builder) => {
|
|
26
28
|
(0, prototype_utils_1.patchPrototype)(builder, extension);
|
|
@@ -54,3 +54,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
|
|
|
54
54
|
interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereDistinctMethods {
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
|
|
58
|
+
interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereDistinctMethods {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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");
|
|
4
5
|
const prototype_utils_1 = require("../utils/prototype.utils");
|
|
5
6
|
const query_builder_utils_1 = require("../utils/query-builder.utils");
|
|
6
7
|
const sql_utils_1 = require("../utils/sql.utils");
|
|
@@ -23,6 +24,7 @@ const queryBuilders = [
|
|
|
23
24
|
typeorm_1.SelectQueryBuilder,
|
|
24
25
|
typeorm_1.UpdateQueryBuilder,
|
|
25
26
|
typeorm_1.DeleteQueryBuilder,
|
|
27
|
+
SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
|
|
26
28
|
];
|
|
27
29
|
queryBuilders.forEach((builder) => {
|
|
28
30
|
(0, prototype_utils_1.patchPrototype)(builder, extension);
|
|
@@ -39,29 +39,29 @@ declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
|
39
39
|
* If you had previously WHERE expression defined,
|
|
40
40
|
* calling this function will override previously set WHERE conditions.
|
|
41
41
|
*/
|
|
42
|
-
whereIsIn(field: string, array?: ArgsType):
|
|
42
|
+
whereIsIn(field: string, array?: ArgsType): this;
|
|
43
43
|
/**
|
|
44
44
|
* Adds new AND WHERE IN condition in the query builder.
|
|
45
45
|
*/
|
|
46
|
-
andWhereIsIn(field: string, array?: ArgsType):
|
|
46
|
+
andWhereIsIn(field: string, array?: ArgsType): this;
|
|
47
47
|
/**
|
|
48
48
|
* Adds new OR WHERE IN condition in the query builder.
|
|
49
49
|
*/
|
|
50
|
-
orWhereIsIn(field: string, array?: ArgsType):
|
|
50
|
+
orWhereIsIn(field: string, array?: ArgsType): this;
|
|
51
51
|
/**
|
|
52
52
|
* Sets WHERE NOT IN condition in the query builder.
|
|
53
53
|
* If you had previously WHERE expression defined,
|
|
54
54
|
* calling this function will override previously set WHERE conditions.
|
|
55
55
|
*/
|
|
56
|
-
whereIsNotIn(field: string, array?: ArgsType):
|
|
56
|
+
whereIsNotIn(field: string, array?: ArgsType): this;
|
|
57
57
|
/**
|
|
58
58
|
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
59
59
|
*/
|
|
60
|
-
andWhereIsNotIn(field: string, array?: ArgsType):
|
|
60
|
+
andWhereIsNotIn(field: string, array?: ArgsType): this;
|
|
61
61
|
/**
|
|
62
62
|
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
63
63
|
*/
|
|
64
|
-
orWhereIsNotIn(field: string, array?: ArgsType):
|
|
64
|
+
orWhereIsNotIn(field: string, array?: ArgsType): this;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
declare module 'typeorm/query-builder/UpdateQueryBuilder' {
|
|
@@ -128,3 +128,35 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
|
|
|
128
128
|
orWhereIsNotIn(field: string, array?: ArgsType): DeleteQueryBuilder<Entity>;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
|
|
132
|
+
interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> {
|
|
133
|
+
/**
|
|
134
|
+
* Sets WHERE IN condition in the query builder.
|
|
135
|
+
* If you had previously WHERE expression defined,
|
|
136
|
+
* calling this function will override previously set WHERE conditions.
|
|
137
|
+
*/
|
|
138
|
+
whereIsIn(field: string, array?: ArgsType): SoftDeleteQueryBuilder<Entity>;
|
|
139
|
+
/**
|
|
140
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
141
|
+
*/
|
|
142
|
+
andWhereIsIn(field: string, array?: ArgsType): SoftDeleteQueryBuilder<Entity>;
|
|
143
|
+
/**
|
|
144
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
145
|
+
*/
|
|
146
|
+
orWhereIsIn(field: string, array?: ArgsType): SoftDeleteQueryBuilder<Entity>;
|
|
147
|
+
/**
|
|
148
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
149
|
+
* If you had previously WHERE expression defined,
|
|
150
|
+
* calling this function will override previously set WHERE conditions.
|
|
151
|
+
*/
|
|
152
|
+
whereIsNotIn(field: string, array?: ArgsType): SoftDeleteQueryBuilder<Entity>;
|
|
153
|
+
/**
|
|
154
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
155
|
+
*/
|
|
156
|
+
andWhereIsNotIn(field: string, array?: ArgsType): SoftDeleteQueryBuilder<Entity>;
|
|
157
|
+
/**
|
|
158
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
159
|
+
*/
|
|
160
|
+
orWhereIsNotIn(field: string, array?: ArgsType): SoftDeleteQueryBuilder<Entity>;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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");
|
|
4
5
|
const prototype_utils_1 = require("../utils/prototype.utils");
|
|
5
6
|
const where_utils_1 = require("../utils/where.utils");
|
|
6
7
|
// patching
|
|
@@ -30,6 +31,7 @@ const queryBuilders = [
|
|
|
30
31
|
typeorm_1.SelectQueryBuilder,
|
|
31
32
|
typeorm_1.UpdateQueryBuilder,
|
|
32
33
|
typeorm_1.DeleteQueryBuilder,
|
|
34
|
+
SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
|
|
33
35
|
];
|
|
34
36
|
queryBuilders.forEach((builder) => {
|
|
35
37
|
(0, prototype_utils_1.patchPrototype)(builder, extension);
|
|
@@ -53,3 +53,7 @@ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
|
|
|
53
53
|
interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereJsonMethods {
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
|
|
57
|
+
interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereJsonMethods {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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");
|
|
4
5
|
const prototype_utils_1 = require("../utils/prototype.utils");
|
|
5
6
|
const query_builder_utils_1 = require("../utils/query-builder.utils");
|
|
6
7
|
const sql_utils_1 = require("../utils/sql.utils");
|
|
@@ -26,6 +27,7 @@ const queryBuilders = [
|
|
|
26
27
|
typeorm_1.SelectQueryBuilder,
|
|
27
28
|
typeorm_1.UpdateQueryBuilder,
|
|
28
29
|
typeorm_1.DeleteQueryBuilder,
|
|
30
|
+
SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder,
|
|
29
31
|
];
|
|
30
32
|
queryBuilders.forEach((builder) => {
|
|
31
33
|
(0, prototype_utils_1.patchPrototype)(builder, extension);
|
|
@@ -19,17 +19,17 @@ type RelatedCondition<Related extends ObjectLiteral> = (subQuery: SelectQueryBui
|
|
|
19
19
|
*/
|
|
20
20
|
export interface WhereRelationExistsMethods<Entity extends ObjectLiteral> {
|
|
21
21
|
/** Sets `WHERE EXISTS (…)` over the relation, replacing the WHERE conditions set before. */
|
|
22
|
-
whereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
22
|
+
whereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
23
23
|
/** Adds `AND EXISTS (…)` over the relation. */
|
|
24
|
-
andWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
24
|
+
andWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
25
25
|
/** Adds `OR EXISTS (…)` over the relation. */
|
|
26
|
-
orWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
26
|
+
orWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
27
27
|
/** Sets `WHERE NOT EXISTS (…)` over the relation, replacing the WHERE conditions set before. */
|
|
28
|
-
whereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
28
|
+
whereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
29
29
|
/** Adds `AND NOT EXISTS (…)` over the relation. */
|
|
30
|
-
andWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
30
|
+
andWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
31
31
|
/** Adds `OR NOT EXISTS (…)` over the relation. */
|
|
32
|
-
orWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
32
|
+
orWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity, this>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
|
|
33
33
|
}
|
|
34
34
|
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
35
35
|
interface SelectQueryBuilder<Entity extends ObjectLiteral> extends WhereRelationExistsMethods<Entity> {
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export * from './utils/table.utils';
|
|
2
|
+
export * from './decorators/generated-column.decorator';
|
|
2
3
|
export { escapeLikePattern } from './utils/search.utils';
|
|
4
|
+
export { COCKROACHDB_RESERVED_KEY_WORDS, findBareReservedQualifiers, POSTGRES_RESERVED_KEY_WORDS, } from './utils/reserved-qualifier.utils';
|
|
5
|
+
export type { ReservedQualifier } from './utils/reserved-qualifier.utils';
|
|
6
|
+
export { disableReservedQualifierGuard, enableReservedQualifierGuard, ReservedQualifierError, } from './utils/reserved-qualifier-guard.utils';
|
|
7
|
+
export type { ReservedQualifierGuardOptions } from './utils/reserved-qualifier-guard.utils';
|
package/dist/helpers.js
CHANGED
|
@@ -14,10 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.escapeLikePattern = void 0;
|
|
17
|
+
exports.ReservedQualifierError = exports.enableReservedQualifierGuard = exports.disableReservedQualifierGuard = exports.POSTGRES_RESERVED_KEY_WORDS = exports.findBareReservedQualifiers = exports.COCKROACHDB_RESERVED_KEY_WORDS = exports.escapeLikePattern = void 0;
|
|
18
18
|
// Side-effect-free entry point: `typeorm-extensions/helpers`.
|
|
19
|
-
// Exports helpers (tableHelper, escapeLikePattern) only and patches nothing
|
|
20
|
-
// (`typeorm-extensions`) installs every QueryBuilder extension.
|
|
19
|
+
// Exports helpers (tableHelper, escapeLikePattern, the reserved qualifier guard, @GeneratedColumn) only and patches nothing on import;
|
|
20
|
+
// importing the package root (`typeorm-extensions`) installs every QueryBuilder extension.
|
|
21
21
|
__exportStar(require("./utils/table.utils"), exports);
|
|
22
|
+
__exportStar(require("./decorators/generated-column.decorator"), exports);
|
|
22
23
|
var search_utils_1 = require("./utils/search.utils");
|
|
23
24
|
Object.defineProperty(exports, "escapeLikePattern", { enumerable: true, get: function () { return search_utils_1.escapeLikePattern; } });
|
|
25
|
+
var reserved_qualifier_utils_1 = require("./utils/reserved-qualifier.utils");
|
|
26
|
+
Object.defineProperty(exports, "COCKROACHDB_RESERVED_KEY_WORDS", { enumerable: true, get: function () { return reserved_qualifier_utils_1.COCKROACHDB_RESERVED_KEY_WORDS; } });
|
|
27
|
+
Object.defineProperty(exports, "findBareReservedQualifiers", { enumerable: true, get: function () { return reserved_qualifier_utils_1.findBareReservedQualifiers; } });
|
|
28
|
+
Object.defineProperty(exports, "POSTGRES_RESERVED_KEY_WORDS", { enumerable: true, get: function () { return reserved_qualifier_utils_1.POSTGRES_RESERVED_KEY_WORDS; } });
|
|
29
|
+
var reserved_qualifier_guard_utils_1 = require("./utils/reserved-qualifier-guard.utils");
|
|
30
|
+
Object.defineProperty(exports, "disableReservedQualifierGuard", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.disableReservedQualifierGuard; } });
|
|
31
|
+
Object.defineProperty(exports, "enableReservedQualifierGuard", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.enableReservedQualifierGuard; } });
|
|
32
|
+
Object.defineProperty(exports, "ReservedQualifierError", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.ReservedQualifierError; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -6,3 +6,7 @@ export type { Json } from './types/modules/proxy-callback.types';
|
|
|
6
6
|
export type { TypedRoot, WithTypedRoot } from './types/modules/typed-root.types';
|
|
7
7
|
export * from './utils/table.utils';
|
|
8
8
|
export { escapeLikePattern } from './utils/search.utils';
|
|
9
|
+
export { COCKROACHDB_RESERVED_KEY_WORDS, findBareReservedQualifiers, POSTGRES_RESERVED_KEY_WORDS, } from './utils/reserved-qualifier.utils';
|
|
10
|
+
export type { ReservedQualifier } from './utils/reserved-qualifier.utils';
|
|
11
|
+
export { disableReservedQualifierGuard, enableReservedQualifierGuard, ReservedQualifierError, } from './utils/reserved-qualifier-guard.utils';
|
|
12
|
+
export type { ReservedQualifierGuardOptions } from './utils/reserved-qualifier-guard.utils';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.escapeLikePattern = void 0;
|
|
17
|
+
exports.ReservedQualifierError = exports.enableReservedQualifierGuard = exports.disableReservedQualifierGuard = exports.POSTGRES_RESERVED_KEY_WORDS = exports.findBareReservedQualifiers = exports.COCKROACHDB_RESERVED_KEY_WORDS = exports.escapeLikePattern = void 0;
|
|
18
18
|
__exportStar(require("./extensions"), exports);
|
|
19
19
|
__exportStar(require("./decorators"), exports);
|
|
20
20
|
__exportStar(require("./types/interfaces"), exports);
|
|
@@ -22,3 +22,11 @@ __exportStar(require("./types/extensions"), exports);
|
|
|
22
22
|
__exportStar(require("./utils/table.utils"), exports);
|
|
23
23
|
var search_utils_1 = require("./utils/search.utils");
|
|
24
24
|
Object.defineProperty(exports, "escapeLikePattern", { enumerable: true, get: function () { return search_utils_1.escapeLikePattern; } });
|
|
25
|
+
var reserved_qualifier_utils_1 = require("./utils/reserved-qualifier.utils");
|
|
26
|
+
Object.defineProperty(exports, "COCKROACHDB_RESERVED_KEY_WORDS", { enumerable: true, get: function () { return reserved_qualifier_utils_1.COCKROACHDB_RESERVED_KEY_WORDS; } });
|
|
27
|
+
Object.defineProperty(exports, "findBareReservedQualifiers", { enumerable: true, get: function () { return reserved_qualifier_utils_1.findBareReservedQualifiers; } });
|
|
28
|
+
Object.defineProperty(exports, "POSTGRES_RESERVED_KEY_WORDS", { enumerable: true, get: function () { return reserved_qualifier_utils_1.POSTGRES_RESERVED_KEY_WORDS; } });
|
|
29
|
+
var reserved_qualifier_guard_utils_1 = require("./utils/reserved-qualifier-guard.utils");
|
|
30
|
+
Object.defineProperty(exports, "disableReservedQualifierGuard", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.disableReservedQualifierGuard; } });
|
|
31
|
+
Object.defineProperty(exports, "enableReservedQualifierGuard", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.enableReservedQualifierGuard; } });
|
|
32
|
+
Object.defineProperty(exports, "ReservedQualifierError", { enumerable: true, get: function () { return reserved_qualifier_guard_utils_1.ReservedQualifierError; } });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CursorOrderParam } from '../interfaces/cursor-pagination.interface';
|
|
2
|
+
import type { OrderType } from '../interfaces/ordering.interface';
|
|
2
3
|
export type GetManyWithCursorOptions<Entity> = {
|
|
3
4
|
/**
|
|
4
5
|
* Columns that order the rows, e.g. `[{ field: 'createdAt', direction: 'DESC' }]`.
|
|
@@ -18,4 +19,8 @@ export interface ListWithCursor<Entity> {
|
|
|
18
19
|
* keyset query loads `pageSize + 1` rows, so it needs no total. Equivalent to `nextCursor !== null`.
|
|
19
20
|
*/
|
|
20
21
|
hasMore: boolean;
|
|
22
|
+
/** The page size used: the `pageSize` given, rounded down, or `10` when it was missing or below 1. */
|
|
23
|
+
pageSize: number;
|
|
24
|
+
/** The ORDER BY the page was read in: the `orderBy` columns, then the primary key columns not among them. */
|
|
25
|
+
orderBy: OrderType[];
|
|
21
26
|
}
|
|
@@ -18,6 +18,10 @@ export type GetRawManyWithTotalsOptions = Omit<GetManyWithTotalsOptions, 'useTak
|
|
|
18
18
|
export interface ListWithTotals<Entity> {
|
|
19
19
|
list: Entity[];
|
|
20
20
|
total: number | null;
|
|
21
|
+
/** The page read, 1-based: the `page` given, or `1` when it was missing or below 1. `null` with `loadAll`. */
|
|
22
|
+
page: number | null;
|
|
23
|
+
/** The page size used: the `pageSize` given, or `10` when it was missing or below 1. `null` with `loadAll`. */
|
|
24
|
+
pageSize: number | null;
|
|
21
25
|
limit: number | null;
|
|
22
26
|
offset: number | null;
|
|
23
27
|
/**
|
|
@@ -26,4 +26,5 @@ __exportStar(require("./search.types"), exports);
|
|
|
26
26
|
__exportStar(require("./typed-having.types"), exports);
|
|
27
27
|
__exportStar(require("./union.types"), exports);
|
|
28
28
|
__exportStar(require("./join-lateral.types"), exports);
|
|
29
|
+
__exportStar(require("./typed-join-and-map.types"), exports);
|
|
29
30
|
__exportStar(require("./query-returning.types"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SelectQueryBuilder } from 'typeorm';
|
|
2
|
+
/**
|
|
3
|
+
* What a map join joins, as TypeORM's `leftJoinAndMapOne` and the others take it: an entity class or name, a
|
|
4
|
+
* relation (`'user.photos'`), a table name, or a factory that builds a subquery on the query builder it is given.
|
|
5
|
+
*/
|
|
6
|
+
export type JoinAndMapTarget = Function | string | ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import type { ObjectLiteral } from 'typeorm';
|
|
2
|
-
declare const typedRoot: unique symbol;
|
|
3
2
|
declare class TypedRootMark<Root> {
|
|
4
|
-
|
|
3
|
+
__typedRoot?(): Root;
|
|
5
4
|
}
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
* with an optional
|
|
6
|
+
* A query builder whose typed callbacks take another root, as `typed<Root>()` returns it:
|
|
7
|
+
* `WithTypedRoot<SelectQueryBuilder<Entity>, Root>`, the builder with an optional `__typedRoot` method that only
|
|
8
|
+
* types carry. A builder of a marked entity, `SelectQueryBuilder<WithTypedRoot<Entity, Root>>`, takes the root too.
|
|
9
9
|
*/
|
|
10
|
-
export type WithTypedRoot<
|
|
10
|
+
export type WithTypedRoot<Marked, Root extends ObjectLiteral> = Marked & TypedRootMark<Root>;
|
|
11
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
12
|
+
type BuilderRoot<Builder> = '__typedRoot' extends keyof Builder ? Builder extends TypedRootMark<infer Root> ? Root extends ObjectLiteral ? Root : never : never : never;
|
|
13
|
+
type EntityRoot<Entity> = '__typedRoot' extends keyof Entity ? IsAny<Entity['__typedRoot' & keyof Entity]> extends true ? Entity : Entity extends TypedRootMark<infer Root> ? Root extends ObjectLiteral ? Root : Entity : Entity : Entity;
|
|
11
14
|
/**
|
|
12
|
-
* The root of a builder's typed callbacks: the one set with `typed<Root>()
|
|
13
|
-
*
|
|
14
|
-
* optional mark too, and its root would be inferred as `unknown`.
|
|
15
|
+
* The root of a builder's typed callbacks: the one set with `typed<Root>()` on the builder (`Builder`, which the
|
|
16
|
+
* typed methods pass as `this`) or on its entity, or else the entity.
|
|
15
17
|
*/
|
|
16
|
-
export type TypedRoot<Entity
|
|
18
|
+
export type TypedRoot<Entity, Builder = unknown> = [BuilderRoot<Builder>] extends [never] ? EntityRoot<Entity> : BuilderRoot<Builder>;
|
|
17
19
|
export {};
|
|
@@ -11,6 +11,6 @@ const getLimitAndOffset = ({ page, pageSize }) => {
|
|
|
11
11
|
}
|
|
12
12
|
const offset = (page >= 1 ? page - 1 : 0) * pageSize;
|
|
13
13
|
const limit = pageSize;
|
|
14
|
-
return { limit, offset };
|
|
14
|
+
return { limit, offset, page, pageSize };
|
|
15
15
|
};
|
|
16
16
|
exports.getLimitAndOffset = getLimitAndOffset;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { QueryBuilder } from 'typeorm';
|
|
1
2
|
import type { ObjectLiteral, WhereExpressionBuilder } from 'typeorm';
|
|
2
3
|
import type { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata';
|
|
3
4
|
import type { KeyProxyCallback } from '../types/modules/proxy-callback.types';
|
|
5
|
+
import type { OrderType } from '../types/interfaces/ordering.interface';
|
|
4
6
|
import { JsonPathSqlOptions } from './json-path.utils';
|
|
5
7
|
/** Replaces placeholders of `deferColumnKey` in SQL built by `builder`, through the aliases it has by then. */
|
|
6
8
|
export declare function resolveDeferredKeys(builder: WhereExpressionBuilder, statement: string): string;
|
|
@@ -54,8 +56,15 @@ export declare function getTypedSingleColumnKey<Type extends ObjectLiteral>(buil
|
|
|
54
56
|
* Without quotes it is `alias.propertyPath` (`user.name`, `images.url`, `p.address.city`),
|
|
55
57
|
* which TypeORM maps to the column itself. With `useQuotes` it is the quoted database column
|
|
56
58
|
* (`"t"."ticket_status"`), since TypeORM doesn't map quoted keys. An alias of the query without
|
|
57
|
-
* metadata (a subquery or a CTE in FROM or a join)
|
|
58
|
-
* TypeORM leaves its keys as written, and
|
|
59
|
+
* metadata (a subquery or a CTE in FROM or a join), or one the query still doesn't have when the SQL
|
|
60
|
+
* is built, is quoted unless `useQuotes` is `false`: TypeORM leaves its keys as written, and
|
|
61
|
+
* PostgreSQL folds an unquoted `cte.firstName` to `firstname`.
|
|
59
62
|
* Strings are kept as is.
|
|
60
63
|
*/
|
|
61
64
|
export declare function getTypedSelectionKey<Type extends ObjectLiteral>(builder: WhereExpressionBuilder, selection: KeyProxyCallback<Type> | string, useQuotes?: boolean, columnsFor?: string): string | string[];
|
|
65
|
+
/**
|
|
66
|
+
* The ORDER BY a query is built with, in the order it was applied. `allOrderBys`, not `orderBys`: it is what the SQL
|
|
67
|
+
* is built from, so without an explicit order it falls back to the `orderBy` of @Entity, and respects the
|
|
68
|
+
* `disable-global-order` option.
|
|
69
|
+
*/
|
|
70
|
+
export declare function getAppliedOrderBy<Entity extends ObjectLiteral>(builder: QueryBuilder<Entity>): OrderType[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTypedSelectionKey = exports.getTypedSingleColumnKey = exports.isTypedJsonPath = exports.getTypedColumnKey = exports.toFieldSql = exports.findFieldColumn = exports.getColumnDatabaseName = exports.resolveDeferredKeys = void 0;
|
|
3
|
+
exports.getAppliedOrderBy = exports.getTypedSelectionKey = exports.getTypedSingleColumnKey = exports.isTypedJsonPath = exports.getTypedColumnKey = exports.toFieldSql = exports.findFieldColumn = exports.getColumnDatabaseName = exports.resolveDeferredKeys = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
5
|
const QueryExpressionMap_1 = require("typeorm/query-builder/QueryExpressionMap");
|
|
6
6
|
const proxy_key_utils_1 = require("./proxy-key.utils");
|
|
@@ -70,12 +70,13 @@ function deferColumnKey(aliasName, separator, name) {
|
|
|
70
70
|
* quoted without an entity;
|
|
71
71
|
* - an unquoted one (select, order, group by, distinct without `useQuotes`): `alias.property` on an alias with an
|
|
72
72
|
* entity, which TypeORM maps and reads as a column of the entity; quoted on an alias without one (a subquery, a
|
|
73
|
-
* CTE), as on an alias known at the call
|
|
73
|
+
* CTE), as on an alias known at the call, and on an alias the query never has, which only raw SQL adds (a LATERAL
|
|
74
|
+
* subquery in the condition of a raw join): TypeORM can't map it, and PostgreSQL would fold it to lower case.
|
|
74
75
|
*/
|
|
75
76
|
function toDeferredKeySql(alias, aliasName, separator, name, escape) {
|
|
76
77
|
const metadata = (alias === null || alias === void 0 ? void 0 : alias.hasMetadata) ? alias.metadata : undefined;
|
|
77
78
|
if (separator === DEFERRED_UNQUOTED) {
|
|
78
|
-
return metadata
|
|
79
|
+
return metadata ? `${aliasName}.${name}` : `${escape(aliasName)}.${escape(name)}`;
|
|
79
80
|
}
|
|
80
81
|
const column = metadata && (separator === DEFERRED_FIELD ? findColumn(metadata, name) : metadata.findColumnWithPropertyPath(name));
|
|
81
82
|
const columnName = column && !column.isVirtualProperty ? column.databaseName : name;
|
|
@@ -403,8 +404,9 @@ function isAliasWithoutMetadata(queryBuilder, aliasName) {
|
|
|
403
404
|
* Without quotes it is `alias.propertyPath` (`user.name`, `images.url`, `p.address.city`),
|
|
404
405
|
* which TypeORM maps to the column itself. With `useQuotes` it is the quoted database column
|
|
405
406
|
* (`"t"."ticket_status"`), since TypeORM doesn't map quoted keys. An alias of the query without
|
|
406
|
-
* metadata (a subquery or a CTE in FROM or a join)
|
|
407
|
-
* TypeORM leaves its keys as written, and
|
|
407
|
+
* metadata (a subquery or a CTE in FROM or a join), or one the query still doesn't have when the SQL
|
|
408
|
+
* is built, is quoted unless `useQuotes` is `false`: TypeORM leaves its keys as written, and
|
|
409
|
+
* PostgreSQL folds an unquoted `cte.firstName` to `firstname`.
|
|
408
410
|
* Strings are kept as is.
|
|
409
411
|
*/
|
|
410
412
|
function getTypedSelectionKey(builder, selection, useQuotes, columnsFor) {
|
|
@@ -440,3 +442,18 @@ function getTypedSelectionKey(builder, selection, useQuotes, columnsFor) {
|
|
|
440
442
|
return Array.isArray(keyHolder) ? keyHolder.map(toKey) : toKey(keyHolder);
|
|
441
443
|
}
|
|
442
444
|
exports.getTypedSelectionKey = getTypedSelectionKey;
|
|
445
|
+
/**
|
|
446
|
+
* The ORDER BY a query is built with, in the order it was applied. `allOrderBys`, not `orderBys`: it is what the SQL
|
|
447
|
+
* is built from, so without an explicit order it falls back to the `orderBy` of @Entity, and respects the
|
|
448
|
+
* `disable-global-order` option.
|
|
449
|
+
*/
|
|
450
|
+
function getAppliedOrderBy(builder) {
|
|
451
|
+
var _a;
|
|
452
|
+
return Object.entries((_a = builder.expressionMap.allOrderBys) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => {
|
|
453
|
+
const selector = resolveDeferredKeys(builder, key);
|
|
454
|
+
return typeof value === 'string'
|
|
455
|
+
? { selector, order: value }
|
|
456
|
+
: { selector, order: value.order, nulls: value.nulls };
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
exports.getAppliedOrderBy = getAppliedOrderBy;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReservedQualifier } from './reserved-qualifier.utils';
|
|
2
|
+
/** The SQL of a query names a reserved word as a qualifier without quotes; see `enableReservedQualifierGuard`. */
|
|
3
|
+
export declare class ReservedQualifierError extends Error {
|
|
4
|
+
/** The SQL of the query, as the driver gets it. */
|
|
5
|
+
readonly sql: string;
|
|
6
|
+
/** Each reserved word used as a qualifier, in the order of the SQL. */
|
|
7
|
+
readonly qualifiers: ReservedQualifier[];
|
|
8
|
+
constructor(sql: string, qualifiers: ReservedQualifier[]);
|
|
9
|
+
}
|
|
10
|
+
type GuardWordsOption = {
|
|
11
|
+
/**
|
|
12
|
+
* The words to report, instead of the default list of the database (`POSTGRES_RESERVED_KEY_WORDS`,
|
|
13
|
+
* `COCKROACHDB_RESERVED_KEY_WORDS` on CockroachDB). Spread a default list to extend it.
|
|
14
|
+
*/
|
|
15
|
+
words?: readonly string[];
|
|
16
|
+
};
|
|
17
|
+
export type ReservedQualifierGuardOptions = GuardWordsOption & ({
|
|
18
|
+
/** `'throw'` (the default): the query rejects with a `ReservedQualifierError` before it runs. */
|
|
19
|
+
mode?: 'throw';
|
|
20
|
+
} | {
|
|
21
|
+
/** `'warn'`: the query runs, and the error is passed to `onViolation`. */
|
|
22
|
+
mode: 'warn';
|
|
23
|
+
/** Reports the error the query would throw in `'throw'` mode; `console.warn` by default. */
|
|
24
|
+
onViolation?: (violation: ReservedQualifierError) => void;
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Checks the SQL of every query builder on PostgreSQL and CockroachDB for a reserved word used as a qualifier
|
|
28
|
+
* without quotes, such as `order."userId"` or `user.id` (`findBareReservedQualifiers`), before the query runs.
|
|
29
|
+
* TypeORM quotes the aliases it writes, so such a word comes from SQL written by hand, which PostgreSQL rejects.
|
|
30
|
+
*
|
|
31
|
+
* Off by default. A second call replaces the options. Other databases aren't checked.
|
|
32
|
+
*/
|
|
33
|
+
export declare function enableReservedQualifierGuard(options?: ReservedQualifierGuardOptions): void;
|
|
34
|
+
/** Turns the check of `enableReservedQualifierGuard` off. */
|
|
35
|
+
export declare function disableReservedQualifierGuard(): void;
|
|
36
|
+
export {};
|