typeorm 0.3.23-dev.fe71a0c → 0.3.24-dev.1198dc2
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/browser/common/PrimitiveCriteria.d.ts +2 -0
- package/browser/common/PrimitiveCriteria.js +3 -0
- package/browser/common/PrimitiveCriteria.js.map +1 -0
- package/browser/data-source/BaseDataSourceOptions.d.ts +1 -1
- package/browser/data-source/BaseDataSourceOptions.js.map +1 -1
- package/browser/data-source/DataSource.d.ts +8 -0
- package/browser/data-source/DataSource.js +18 -1
- package/browser/data-source/DataSource.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.d.ts +8 -8
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +16 -16
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/cordova/CordovaQueryRunner.js +6 -6
- package/browser/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/browser/driver/expo/ExpoQueryRunner.js +5 -4
- package/browser/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/MongoQueryRunner.d.ts +4 -0
- package/browser/driver/mongodb/MongoQueryRunner.js +6 -0
- package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.d.ts +7 -7
- package/browser/driver/mysql/MysqlQueryRunner.js +16 -16
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/nativescript/NativescriptQueryRunner.js +4 -4
- package/browser/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.d.ts +7 -7
- package/browser/driver/oracle/OracleQueryRunner.js +13 -13
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +2 -2
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/react-native/ReactNativeQueryRunner.js +53 -46
- package/browser/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.d.ts +1 -1
- package/browser/driver/sap/SapQueryRunner.js +46 -23
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/spanner/SpannerQueryRunner.js +6 -6
- package/browser/driver/spanner/SpannerQueryRunner.js.map +1 -1
- package/browser/driver/sqlite/SqliteQueryRunner.js +9 -9
- package/browser/driver/sqlite/SqliteQueryRunner.js.map +1 -1
- package/browser/driver/sqljs/SqljsQueryRunner.js +5 -5
- package/browser/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.d.ts +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +7 -7
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/entity-manager/EntityManager.d.ts +8 -0
- package/browser/entity-manager/EntityManager.js +25 -32
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/error/index.d.ts +0 -1
- package/browser/error/index.js +0 -1
- package/browser/error/index.js.map +1 -1
- package/browser/index.d.ts +1 -0
- package/browser/index.js +1 -0
- package/browser/index.js.map +1 -1
- package/browser/logger/AbstractLogger.d.ts +1 -1
- package/browser/logger/AbstractLogger.js +5 -1
- package/browser/logger/AbstractLogger.js.map +1 -1
- package/browser/logger/FormattedConsoleLogger.d.ts +13 -0
- package/browser/logger/FormattedConsoleLogger.js +55 -0
- package/browser/logger/FormattedConsoleLogger.js.map +1 -0
- package/browser/logger/Logger.d.ts +1 -0
- package/browser/logger/Logger.js.map +1 -1
- package/browser/logger/LoggerFactory.d.ts +1 -1
- package/browser/logger/LoggerFactory.js +3 -0
- package/browser/logger/LoggerFactory.js.map +1 -1
- package/browser/persistence/SubjectChangedColumnsComputer.js +23 -9
- package/browser/persistence/SubjectChangedColumnsComputer.js.map +1 -1
- package/browser/persistence/SubjectDatabaseEntityLoader.d.ts +0 -8
- package/browser/persistence/SubjectDatabaseEntityLoader.js +11 -26
- package/browser/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/browser/platform/PlatformTools.d.ts +5 -0
- package/browser/platform/PlatformTools.js +16 -0
- package/browser/platform/PlatformTools.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.d.ts +8 -0
- package/browser/query-runner/BaseQueryRunner.js +16 -0
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/browser/query-runner/QueryResult.d.ts +2 -2
- package/browser/query-runner/QueryResult.js.map +1 -1
- package/browser/query-runner/QueryRunner.d.ts +8 -0
- package/browser/query-runner/QueryRunner.js.map +1 -1
- package/browser/repository/Repository.d.ts +13 -5
- package/browser/repository/Repository.js +16 -0
- package/browser/repository/Repository.js.map +1 -1
- package/browser/subscriber/Broadcaster.d.ts +6 -6
- package/browser/subscriber/Broadcaster.js +1 -1
- package/browser/subscriber/Broadcaster.js.map +1 -1
- package/browser/util/OrmUtils.d.ts +18 -4
- package/browser/util/OrmUtils.js +97 -69
- package/browser/util/OrmUtils.js.map +1 -1
- package/browser/util/SqlTagUtils.d.ts +11 -0
- package/browser/util/SqlTagUtils.js +39 -0
- package/browser/util/SqlTagUtils.js.map +1 -0
- package/common/PrimitiveCriteria.d.ts +2 -0
- package/common/PrimitiveCriteria.js +4 -0
- package/common/PrimitiveCriteria.js.map +1 -0
- package/data-source/BaseDataSourceOptions.d.ts +1 -1
- package/data-source/BaseDataSourceOptions.js.map +1 -1
- package/data-source/DataSource.d.ts +8 -0
- package/data-source/DataSource.js +18 -1
- package/data-source/DataSource.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.d.ts +8 -8
- package/driver/cockroachdb/CockroachQueryRunner.js +16 -16
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/cordova/CordovaQueryRunner.js +6 -6
- package/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/driver/expo/ExpoQueryRunner.js +5 -4
- package/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/driver/mongodb/MongoQueryRunner.d.ts +4 -0
- package/driver/mongodb/MongoQueryRunner.js +6 -0
- package/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.d.ts +7 -7
- package/driver/mysql/MysqlQueryRunner.js +16 -16
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/nativescript/NativescriptQueryRunner.js +4 -4
- package/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.d.ts +7 -7
- package/driver/oracle/OracleQueryRunner.js +13 -13
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +2 -2
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/react-native/ReactNativeQueryRunner.js +53 -46
- package/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.d.ts +1 -1
- package/driver/sap/SapQueryRunner.js +46 -23
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/spanner/SpannerQueryRunner.js +6 -6
- package/driver/spanner/SpannerQueryRunner.js.map +1 -1
- package/driver/sqlite/SqliteQueryRunner.js +9 -9
- package/driver/sqlite/SqliteQueryRunner.js.map +1 -1
- package/driver/sqljs/SqljsQueryRunner.js +5 -5
- package/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.d.ts +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.js +7 -7
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/entity-manager/EntityManager.d.ts +8 -0
- package/entity-manager/EntityManager.js +25 -32
- package/entity-manager/EntityManager.js.map +1 -1
- package/error/index.d.ts +0 -1
- package/error/index.js +0 -1
- package/error/index.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/index.mjs +2 -2
- package/logger/AbstractLogger.d.ts +1 -1
- package/logger/AbstractLogger.js +5 -1
- package/logger/AbstractLogger.js.map +1 -1
- package/logger/FormattedConsoleLogger.d.ts +13 -0
- package/logger/FormattedConsoleLogger.js +59 -0
- package/logger/FormattedConsoleLogger.js.map +1 -0
- package/logger/Logger.d.ts +1 -0
- package/logger/Logger.js.map +1 -1
- package/logger/LoggerFactory.d.ts +1 -1
- package/logger/LoggerFactory.js +3 -0
- package/logger/LoggerFactory.js.map +1 -1
- package/package.json +1 -1
- package/persistence/SubjectChangedColumnsComputer.js +23 -9
- package/persistence/SubjectChangedColumnsComputer.js.map +1 -1
- package/persistence/SubjectDatabaseEntityLoader.d.ts +0 -8
- package/persistence/SubjectDatabaseEntityLoader.js +11 -26
- package/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/platform/PlatformTools.d.ts +5 -0
- package/platform/PlatformTools.js +16 -0
- package/platform/PlatformTools.js.map +1 -1
- package/query-runner/BaseQueryRunner.d.ts +8 -0
- package/query-runner/BaseQueryRunner.js +16 -0
- package/query-runner/BaseQueryRunner.js.map +1 -1
- package/query-runner/QueryResult.d.ts +2 -2
- package/query-runner/QueryResult.js.map +1 -1
- package/query-runner/QueryRunner.d.ts +8 -0
- package/query-runner/QueryRunner.js.map +1 -1
- package/repository/Repository.d.ts +13 -5
- package/repository/Repository.js +16 -0
- package/repository/Repository.js.map +1 -1
- package/subscriber/Broadcaster.d.ts +6 -6
- package/subscriber/Broadcaster.js +1 -1
- package/subscriber/Broadcaster.js.map +1 -1
- package/util/OrmUtils.d.ts +18 -4
- package/util/OrmUtils.js +97 -69
- package/util/OrmUtils.js.map +1 -1
- package/util/SqlTagUtils.d.ts +11 -0
- package/util/SqlTagUtils.js +43 -0
- package/util/SqlTagUtils.js.map +1 -0
- package/browser/error/NamingStrategyNotFoundError.d.ts +0 -7
- package/browser/error/NamingStrategyNotFoundError.js +0 -17
- package/browser/error/NamingStrategyNotFoundError.js.map +0 -1
- package/error/NamingStrategyNotFoundError.d.ts +0 -7
- package/error/NamingStrategyNotFoundError.js +0 -21
- package/error/NamingStrategyNotFoundError.js.map +0 -1
package/browser/util/OrmUtils.js
CHANGED
|
@@ -47,75 +47,6 @@ export class OrmUtils {
|
|
|
47
47
|
return uniqueArray;
|
|
48
48
|
}, []);
|
|
49
49
|
}
|
|
50
|
-
// Checks if it's an object made by Object.create(null), {} or new Object()
|
|
51
|
-
static isPlainObject(item) {
|
|
52
|
-
if (item === null || item === undefined) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return !item.constructor || item.constructor === Object;
|
|
56
|
-
}
|
|
57
|
-
static mergeArrayKey(target, key, value, memo) {
|
|
58
|
-
// Have we seen this before? Prevent infinite recursion.
|
|
59
|
-
if (memo.has(value)) {
|
|
60
|
-
target[key] = memo.get(value);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (value instanceof Promise) {
|
|
64
|
-
// Skip promises entirely.
|
|
65
|
-
// This is a hold-over from the old code & is because we don't want to pull in
|
|
66
|
-
// the lazy fields. Ideally we'd remove these promises via another function first
|
|
67
|
-
// but for now we have to do it here.
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!this.isPlainObject(value) && !Array.isArray(value)) {
|
|
71
|
-
target[key] = value;
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (!target[key]) {
|
|
75
|
-
target[key] = Array.isArray(value) ? [] : {};
|
|
76
|
-
}
|
|
77
|
-
memo.set(value, target[key]);
|
|
78
|
-
this.merge(target[key], value, memo);
|
|
79
|
-
memo.delete(value);
|
|
80
|
-
}
|
|
81
|
-
static mergeObjectKey(target, key, value, memo) {
|
|
82
|
-
// Have we seen this before? Prevent infinite recursion.
|
|
83
|
-
if (memo.has(value)) {
|
|
84
|
-
Object.assign(target, { [key]: memo.get(value) });
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (value instanceof Promise) {
|
|
88
|
-
// Skip promises entirely.
|
|
89
|
-
// This is a hold-over from the old code & is because we don't want to pull in
|
|
90
|
-
// the lazy fields. Ideally we'd remove these promises via another function first
|
|
91
|
-
// but for now we have to do it here.
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (!this.isPlainObject(value) && !Array.isArray(value)) {
|
|
95
|
-
Object.assign(target, { [key]: value });
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (!target[key]) {
|
|
99
|
-
Object.assign(target, { [key]: Array.isArray(value) ? [] : {} });
|
|
100
|
-
}
|
|
101
|
-
memo.set(value, target[key]);
|
|
102
|
-
this.merge(target[key], value, memo);
|
|
103
|
-
memo.delete(value);
|
|
104
|
-
}
|
|
105
|
-
static merge(target, source, memo = new Map()) {
|
|
106
|
-
if (this.isPlainObject(target) && this.isPlainObject(source)) {
|
|
107
|
-
for (const key of Object.keys(source)) {
|
|
108
|
-
if (key === "__proto__")
|
|
109
|
-
continue;
|
|
110
|
-
this.mergeObjectKey(target, key, source[key], memo);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (Array.isArray(target) && Array.isArray(source)) {
|
|
114
|
-
for (let key = 0; key < source.length; key++) {
|
|
115
|
-
this.mergeArrayKey(target, key, source[key], memo);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
50
|
/**
|
|
120
51
|
* Deep Object.assign.
|
|
121
52
|
*/
|
|
@@ -323,6 +254,34 @@ export class OrmUtils {
|
|
|
323
254
|
}
|
|
324
255
|
return undefined;
|
|
325
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Checks if given criteria is null or empty.
|
|
259
|
+
*/
|
|
260
|
+
static isCriteriaNullOrEmpty(criteria) {
|
|
261
|
+
return (criteria === undefined ||
|
|
262
|
+
criteria === null ||
|
|
263
|
+
criteria === "" ||
|
|
264
|
+
(Array.isArray(criteria) && criteria.length === 0) ||
|
|
265
|
+
(this.isPlainObject(criteria) && Object.keys(criteria).length === 0));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Checks if given criteria is a primitive value.
|
|
269
|
+
* Primitive values are strings, numbers and dates.
|
|
270
|
+
*/
|
|
271
|
+
static isSinglePrimitiveCriteria(criteria) {
|
|
272
|
+
return (typeof criteria === "string" ||
|
|
273
|
+
typeof criteria === "number" ||
|
|
274
|
+
criteria instanceof Date);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Checks if given criteria is a primitive value or an array of primitive values.
|
|
278
|
+
*/
|
|
279
|
+
static isPrimitiveCriteria(criteria) {
|
|
280
|
+
if (Array.isArray(criteria)) {
|
|
281
|
+
return criteria.every((value) => this.isSinglePrimitiveCriteria(value));
|
|
282
|
+
}
|
|
283
|
+
return this.isSinglePrimitiveCriteria(criteria);
|
|
284
|
+
}
|
|
326
285
|
// -------------------------------------------------------------------------
|
|
327
286
|
// Private methods
|
|
328
287
|
// -------------------------------------------------------------------------
|
|
@@ -406,6 +365,75 @@ export class OrmUtils {
|
|
|
406
365
|
}
|
|
407
366
|
return true;
|
|
408
367
|
}
|
|
368
|
+
// Checks if it's an object made by Object.create(null), {} or new Object()
|
|
369
|
+
static isPlainObject(item) {
|
|
370
|
+
if (item === null || item === undefined) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
return !item.constructor || item.constructor === Object;
|
|
374
|
+
}
|
|
375
|
+
static mergeArrayKey(target, key, value, memo) {
|
|
376
|
+
// Have we seen this before? Prevent infinite recursion.
|
|
377
|
+
if (memo.has(value)) {
|
|
378
|
+
target[key] = memo.get(value);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (value instanceof Promise) {
|
|
382
|
+
// Skip promises entirely.
|
|
383
|
+
// This is a hold-over from the old code & is because we don't want to pull in
|
|
384
|
+
// the lazy fields. Ideally we'd remove these promises via another function first
|
|
385
|
+
// but for now we have to do it here.
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (!this.isPlainObject(value) && !Array.isArray(value)) {
|
|
389
|
+
target[key] = value;
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (!target[key]) {
|
|
393
|
+
target[key] = Array.isArray(value) ? [] : {};
|
|
394
|
+
}
|
|
395
|
+
memo.set(value, target[key]);
|
|
396
|
+
this.merge(target[key], value, memo);
|
|
397
|
+
memo.delete(value);
|
|
398
|
+
}
|
|
399
|
+
static mergeObjectKey(target, key, value, memo) {
|
|
400
|
+
// Have we seen this before? Prevent infinite recursion.
|
|
401
|
+
if (memo.has(value)) {
|
|
402
|
+
Object.assign(target, { [key]: memo.get(value) });
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (value instanceof Promise) {
|
|
406
|
+
// Skip promises entirely.
|
|
407
|
+
// This is a hold-over from the old code & is because we don't want to pull in
|
|
408
|
+
// the lazy fields. Ideally we'd remove these promises via another function first
|
|
409
|
+
// but for now we have to do it here.
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (!this.isPlainObject(value) && !Array.isArray(value)) {
|
|
413
|
+
Object.assign(target, { [key]: value });
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (!target[key]) {
|
|
417
|
+
Object.assign(target, { [key]: Array.isArray(value) ? [] : {} });
|
|
418
|
+
}
|
|
419
|
+
memo.set(value, target[key]);
|
|
420
|
+
this.merge(target[key], value, memo);
|
|
421
|
+
memo.delete(value);
|
|
422
|
+
}
|
|
423
|
+
static merge(target, source, memo = new Map()) {
|
|
424
|
+
if (this.isPlainObject(target) && this.isPlainObject(source)) {
|
|
425
|
+
for (const key of Object.keys(source)) {
|
|
426
|
+
if (key === "__proto__")
|
|
427
|
+
continue;
|
|
428
|
+
this.mergeObjectKey(target, key, source[key], memo);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
432
|
+
for (let key = 0; key < source.length; key++) {
|
|
433
|
+
this.mergeArrayKey(target, key, source[key], memo);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
409
437
|
}
|
|
410
438
|
|
|
411
439
|
//# sourceMappingURL=OrmUtils.js.map
|
|
@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,CAAC;gBAClB,KAAK,QAAQ,CAAC;gBACd,KAAK,UAAU;oBACX,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBACjB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBAElB,IACI,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1D,CAAC;wBACC,OAAO,KAAK,CAAA;oBAChB,CAAC;oBAED,SAAS,CAAC,GAAG,EAAE,CAAA;oBACf,UAAU,CAAC,GAAG,EAAE,CAAA;oBAChB,MAAK;gBAET;oBACI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;wBAChB,OAAO,KAAK,CAAA;oBAChB,CAAC;oBACD,MAAK;YACb,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAA;IACf,CAAC;CACJ","file":"OrmUtils.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\n\nexport class OrmUtils {\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n /**\n * Chunks array into pieces.\n */\n static chunk<T>(array: T[], size: number): T[][] {\n return Array.from(Array(Math.ceil(array.length / size)), (_, i) => {\n return array.slice(i * size, i * size + size)\n })\n }\n\n static splitClassesAndStrings<T>(\n classesAndStrings: (string | T)[],\n ): [T[], string[]] {\n return [\n classesAndStrings.filter(\n (cls): cls is T => typeof cls !== \"string\",\n ),\n classesAndStrings.filter(\n (str): str is string => typeof str === \"string\",\n ),\n ]\n }\n\n static groupBy<T, R>(\n array: T[],\n propertyCallback: (item: T) => R,\n ): { id: R; items: T[] }[] {\n return array.reduce((groupedArray, value) => {\n const key = propertyCallback(value)\n let grouped = groupedArray.find((i) => i.id === key)\n if (!grouped) {\n grouped = { id: key, items: [] }\n groupedArray.push(grouped)\n }\n grouped.items.push(value)\n return groupedArray\n }, [] as Array<{ id: R; items: T[] }>)\n }\n\n static uniq<T>(array: T[], criteria?: (item: T) => any): T[]\n static uniq<T, K extends keyof T>(array: T[], property: K): T[]\n static uniq<T, K extends keyof T>(\n array: T[],\n criteriaOrProperty?: ((item: T) => any) | K,\n ): T[] {\n return array.reduce((uniqueArray, item) => {\n let found: boolean = false\n if (typeof criteriaOrProperty === \"function\") {\n const itemValue = criteriaOrProperty(item)\n found = !!uniqueArray.find(\n (uniqueItem) =>\n criteriaOrProperty(uniqueItem) === itemValue,\n )\n } else if (typeof criteriaOrProperty === \"string\") {\n found = !!uniqueArray.find(\n (uniqueItem) =>\n uniqueItem[criteriaOrProperty] ===\n item[criteriaOrProperty],\n )\n } else {\n found = uniqueArray.indexOf(item) !== -1\n }\n\n if (!found) uniqueArray.push(item)\n\n return uniqueArray\n }, [] as T[])\n }\n\n // Checks if it's an object made by Object.create(null), {} or new Object()\n private static isPlainObject(item: any) {\n if (item === null || item === undefined) {\n return false\n }\n\n return !item.constructor || item.constructor === Object\n }\n\n private static mergeArrayKey(\n target: any,\n key: number,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n target[key] = memo.get(value)\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n target[key] = value\n return\n }\n\n if (!target[key]) {\n target[key] = Array.isArray(value) ? [] : {}\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static mergeObjectKey(\n target: any,\n key: string,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n Object.assign(target, { [key]: memo.get(value) })\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n Object.assign(target, { [key]: value })\n return\n }\n\n if (!target[key]) {\n Object.assign(target, { [key]: Array.isArray(value) ? [] : {} })\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static merge(\n target: any,\n source: any,\n memo: Map<any, any> = new Map(),\n ): any {\n if (this.isPlainObject(target) && this.isPlainObject(source)) {\n for (const key of Object.keys(source)) {\n if (key === \"__proto__\") continue\n this.mergeObjectKey(target, key, source[key], memo)\n }\n }\n\n if (Array.isArray(target) && Array.isArray(source)) {\n for (let key = 0; key < source.length; key++) {\n this.mergeArrayKey(target, key, source[key], memo)\n }\n }\n }\n\n /**\n * Deep Object.assign.\n */\n static mergeDeep(target: any, ...sources: any[]): any {\n if (!sources.length) {\n return target\n }\n\n for (const source of sources) {\n OrmUtils.merge(target, source)\n }\n\n return target\n }\n\n /**\n * Deep compare objects.\n *\n * @see http://stackoverflow.com/a/1144249\n */\n static deepCompare(...args: any[]): boolean {\n let i: any, l: any, leftChain: any, rightChain: any\n\n if (arguments.length < 1) {\n return true // Die silently? Don't know how to handle such case, please help...\n // throw \"Need two or more arguments to compare\";\n }\n\n for (i = 1, l = arguments.length; i < l; i++) {\n leftChain = [] // Todo: this can be cached\n rightChain = []\n\n if (\n !this.compare2Objects(\n leftChain,\n rightChain,\n arguments[0],\n arguments[i],\n )\n ) {\n return false\n }\n }\n\n return true\n }\n\n /**\n * Gets deeper value of object.\n */\n static deepValue(obj: ObjectLiteral, path: string) {\n const segments = path.split(\".\")\n for (let i = 0, len = segments.length; i < len; i++) {\n obj = obj[segments[i]]\n }\n return obj\n }\n\n static replaceEmptyObjectsWithBooleans(obj: any) {\n for (const key in obj) {\n if (obj[key] && typeof obj[key] === \"object\") {\n if (Object.keys(obj[key]).length === 0) {\n obj[key] = true\n } else {\n this.replaceEmptyObjectsWithBooleans(obj[key])\n }\n }\n }\n }\n\n static propertyPathsToTruthyObject(paths: string[]) {\n const obj: any = {}\n for (const path of paths) {\n const props = path.split(\".\")\n if (!props.length) continue\n\n if (!obj[props[0]] || obj[props[0]] === true) {\n obj[props[0]] = {}\n }\n let recursiveChild = obj[props[0]]\n for (const [key, prop] of props.entries()) {\n if (key === 0) continue\n\n if (recursiveChild[prop]) {\n recursiveChild = recursiveChild[prop]\n } else if (key === props.length - 1) {\n recursiveChild[prop] = {}\n recursiveChild = null\n } else {\n recursiveChild[prop] = {}\n recursiveChild = recursiveChild[prop]\n }\n }\n }\n this.replaceEmptyObjectsWithBooleans(obj)\n return obj\n }\n\n /**\n * Check if two entity-id-maps are the same\n */\n static compareIds(\n firstId: ObjectLiteral | undefined,\n secondId: ObjectLiteral | undefined,\n ): boolean {\n if (\n firstId === undefined ||\n firstId === null ||\n secondId === undefined ||\n secondId === null\n )\n return false\n\n // Optimized version for the common case\n if (\n ((typeof firstId.id === \"string\" &&\n typeof secondId.id === \"string\") ||\n (typeof firstId.id === \"number\" &&\n typeof secondId.id === \"number\")) &&\n Object.keys(firstId).length === 1 &&\n Object.keys(secondId).length === 1\n ) {\n return firstId.id === secondId.id\n }\n\n return OrmUtils.deepCompare(firstId, secondId)\n }\n\n /**\n * Transforms given value into boolean value.\n */\n static toBoolean(value: any): boolean {\n if (typeof value === \"boolean\") return value\n\n if (typeof value === \"string\") return value === \"true\" || value === \"1\"\n\n if (typeof value === \"number\") return value > 0\n\n return false\n }\n\n /**\n * Composes an object from the given array of keys and values.\n */\n static zipObject(keys: any[], values: any[]): ObjectLiteral {\n return keys.reduce((object, column, index) => {\n object[column] = values[index]\n return object\n }, {} as ObjectLiteral)\n }\n\n /**\n * Compares two arrays.\n */\n static isArraysEqual(arr1: any[], arr2: any[]): boolean {\n if (arr1.length !== arr2.length) return false\n return arr1.every((element) => {\n return arr2.indexOf(element) !== -1\n })\n }\n\n static areMutuallyExclusive<T>(...lists: T[][]): boolean {\n const haveSharedObjects = lists.some((list) => {\n const otherLists = lists.filter((otherList) => otherList !== list)\n return list.some((item) =>\n otherLists.some((otherList) => otherList.includes(item)),\n )\n })\n return !haveSharedObjects\n }\n\n /**\n * Parses the CHECK constraint on the specified column and returns\n * all values allowed by the constraint or undefined if the constraint\n * is not present.\n */\n static parseSqlCheckExpression(\n sql: string,\n columnName: string,\n ): string[] | undefined {\n const enumMatch = sql.match(\n new RegExp(\n `\"${columnName}\" varchar CHECK\\\\s*\\\\(\\\\s*\"${columnName}\"\\\\s+IN\\\\s*`,\n ),\n )\n\n if (enumMatch && enumMatch.index) {\n const afterMatch = sql.substring(\n enumMatch.index + enumMatch[0].length,\n )\n\n // This is an enum\n // all enum values stored as a comma separated list\n const chars = afterMatch\n\n /**\n * * When outside quotes: empty string\n * * When inside single quotes: `'`\n */\n let currentQuotes = \"\"\n let nextValue = \"\"\n const enumValues: string[] = []\n for (let idx = 0; idx < chars.length; idx++) {\n const char = chars[idx]\n switch (char) {\n case \",\":\n if (currentQuotes == \"\") {\n enumValues.push(nextValue)\n nextValue = \"\"\n } else {\n nextValue += char\n }\n break\n case \"'\":\n if (currentQuotes == char) {\n const isNextCharQuote = chars[idx + 1] === char\n if (isNextCharQuote) {\n // double quote in sql should be treated as a\n // single quote that's part of the quoted string\n nextValue += char\n idx += 1 // skip that next quote\n } else {\n currentQuotes = \"\"\n }\n } else {\n currentQuotes = char\n }\n break\n case \")\":\n if (currentQuotes == \"\") {\n enumValues.push(nextValue)\n return enumValues\n } else {\n nextValue += char\n }\n break\n default:\n if (currentQuotes != \"\") {\n nextValue += char\n }\n }\n }\n }\n return undefined\n }\n\n // -------------------------------------------------------------------------\n // Private methods\n // -------------------------------------------------------------------------\n\n private static compare2Objects(\n leftChain: any,\n rightChain: any,\n x: any,\n y: any,\n ) {\n let p\n\n // remember that NaN === NaN returns false\n // and isNaN(undefined) returns true\n if (Number.isNaN(x) && Number.isNaN(y)) return true\n\n // Compare primitives and functions.\n // Check if both arguments link to the same object.\n // Especially useful on the step where we compare prototypes\n if (x === y) return true\n\n // Unequal, but either is null or undefined (use case: jsonb comparison)\n // PR #3776, todo: add tests\n if (x === null || y === null || x === undefined || y === undefined)\n return false\n\n // Fix the buffer compare bug.\n // See: https://github.com/typeorm/typeorm/issues/3654\n if (\n (typeof x.equals === \"function\" ||\n typeof x.equals === \"function\") &&\n x.equals(y)\n )\n return true\n\n // Works in case when functions are created in constructor.\n // Comparing dates is a common scenario. Another built-ins?\n // We can even handle functions passed across iframes\n if (\n (typeof x === \"function\" && typeof y === \"function\") ||\n (x instanceof Date && y instanceof Date) ||\n (x instanceof RegExp && y instanceof RegExp) ||\n (typeof x === \"string\" && typeof y === \"string\") ||\n (typeof x === \"number\" && typeof y === \"number\")\n )\n return x.toString() === y.toString()\n\n // At last checking prototypes as good as we can\n if (!(typeof x === \"object\" && typeof y === \"object\")) return false\n\n if (\n Object.prototype.isPrototypeOf.call(x, y) ||\n Object.prototype.isPrototypeOf.call(y, x)\n )\n return false\n\n if (x.constructor !== y.constructor) return false\n\n if (x.prototype !== y.prototype) return false\n\n // Check for infinitive linking loops\n if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1)\n return false\n\n // Quick checking of one object being a subset of another.\n // todo: cache the structure of arguments[0] for performance\n for (p in y) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n }\n\n for (p in x) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n\n switch (typeof x[p]) {\n case \"object\":\n case \"function\":\n leftChain.push(x)\n rightChain.push(y)\n\n if (\n !this.compare2Objects(leftChain, rightChain, x[p], y[p])\n ) {\n return false\n }\n\n leftChain.pop()\n rightChain.pop()\n break\n\n default:\n if (x[p] !== y[p]) {\n return false\n }\n break\n }\n }\n\n return true\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3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AAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;gBAC3C,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAA;YACtD,CAAC;QACL,CAAC;IACL,CAAC;CACJ","file":"OrmUtils.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport {\n PrimitiveCriteria,\n SinglePrimitiveCriteria,\n} from \"../common/PrimitiveCriteria\"\n\nexport class OrmUtils {\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n /**\n * Chunks array into pieces.\n */\n public static chunk<T>(array: T[], size: number): T[][] {\n return Array.from(Array(Math.ceil(array.length / size)), (_, i) => {\n return array.slice(i * size, i * size + size)\n })\n }\n\n public static splitClassesAndStrings<T>(\n classesAndStrings: (string | T)[],\n ): [T[], string[]] {\n return [\n classesAndStrings.filter(\n (cls): cls is T => typeof cls !== \"string\",\n ),\n classesAndStrings.filter(\n (str): str is string => typeof str === \"string\",\n ),\n ]\n }\n\n public static groupBy<T, R>(\n array: T[],\n propertyCallback: (item: T) => R,\n ): { id: R; items: T[] }[] {\n return array.reduce((groupedArray, value) => {\n const key = propertyCallback(value)\n let grouped = groupedArray.find((i) => i.id === key)\n if (!grouped) {\n grouped = { id: key, items: [] }\n groupedArray.push(grouped)\n }\n grouped.items.push(value)\n return groupedArray\n }, [] as Array<{ id: R; items: T[] }>)\n }\n\n public static uniq<T>(array: T[], criteria?: (item: T) => any): T[]\n public static uniq<T, K extends keyof T>(array: T[], property: K): T[]\n public static uniq<T, K extends keyof T>(\n array: T[],\n criteriaOrProperty?: ((item: T) => any) | K,\n ): T[] {\n return array.reduce((uniqueArray, item) => {\n let found: boolean = false\n if (typeof criteriaOrProperty === \"function\") {\n const itemValue = criteriaOrProperty(item)\n found = !!uniqueArray.find(\n (uniqueItem) =>\n criteriaOrProperty(uniqueItem) === itemValue,\n )\n } else if (typeof criteriaOrProperty === \"string\") {\n found = !!uniqueArray.find(\n (uniqueItem) =>\n uniqueItem[criteriaOrProperty] ===\n item[criteriaOrProperty],\n )\n } else {\n found = uniqueArray.indexOf(item) !== -1\n }\n\n if (!found) uniqueArray.push(item)\n\n return uniqueArray\n }, [] as T[])\n }\n\n /**\n * Deep Object.assign.\n */\n public static mergeDeep(target: any, ...sources: any[]): any {\n if (!sources.length) {\n return target\n }\n\n for (const source of sources) {\n OrmUtils.merge(target, source)\n }\n\n return target\n }\n\n /**\n * Deep compare objects.\n *\n * @see http://stackoverflow.com/a/1144249\n */\n public static deepCompare(...args: any[]): boolean {\n let i: any, l: any, leftChain: any, rightChain: any\n\n if (arguments.length < 1) {\n return true // Die silently? Don't know how to handle such case, please help...\n // throw \"Need two or more arguments to compare\";\n }\n\n for (i = 1, l = arguments.length; i < l; i++) {\n leftChain = [] // Todo: this can be cached\n rightChain = []\n\n if (\n !this.compare2Objects(\n leftChain,\n rightChain,\n arguments[0],\n arguments[i],\n )\n ) {\n return false\n }\n }\n\n return true\n }\n\n /**\n * Gets deeper value of object.\n */\n public static deepValue(obj: ObjectLiteral, path: string) {\n const segments = path.split(\".\")\n for (let i = 0, len = segments.length; i < len; i++) {\n obj = obj[segments[i]]\n }\n return obj\n }\n\n public static replaceEmptyObjectsWithBooleans(obj: any) {\n for (const key in obj) {\n if (obj[key] && typeof obj[key] === \"object\") {\n if (Object.keys(obj[key]).length === 0) {\n obj[key] = true\n } else {\n this.replaceEmptyObjectsWithBooleans(obj[key])\n }\n }\n }\n }\n\n public static propertyPathsToTruthyObject(paths: string[]) {\n const obj: any = {}\n for (const path of paths) {\n const props = path.split(\".\")\n if (!props.length) continue\n\n if (!obj[props[0]] || obj[props[0]] === true) {\n obj[props[0]] = {}\n }\n let recursiveChild = obj[props[0]]\n for (const [key, prop] of props.entries()) {\n if (key === 0) continue\n\n if (recursiveChild[prop]) {\n recursiveChild = recursiveChild[prop]\n } else if (key === props.length - 1) {\n recursiveChild[prop] = {}\n recursiveChild = null\n } else {\n recursiveChild[prop] = {}\n recursiveChild = recursiveChild[prop]\n }\n }\n }\n this.replaceEmptyObjectsWithBooleans(obj)\n return obj\n }\n\n /**\n * Check if two entity-id-maps are the same\n */\n public static compareIds(\n firstId: ObjectLiteral | undefined,\n secondId: ObjectLiteral | undefined,\n ): boolean {\n if (\n firstId === undefined ||\n firstId === null ||\n secondId === undefined ||\n secondId === null\n )\n return false\n\n // Optimized version for the common case\n if (\n ((typeof firstId.id === \"string\" &&\n typeof secondId.id === \"string\") ||\n (typeof firstId.id === \"number\" &&\n typeof secondId.id === \"number\")) &&\n Object.keys(firstId).length === 1 &&\n Object.keys(secondId).length === 1\n ) {\n return firstId.id === secondId.id\n }\n\n return OrmUtils.deepCompare(firstId, secondId)\n }\n\n /**\n * Transforms given value into boolean value.\n */\n public static toBoolean(value: any): boolean {\n if (typeof value === \"boolean\") return value\n\n if (typeof value === \"string\") return value === \"true\" || value === \"1\"\n\n if (typeof value === \"number\") return value > 0\n\n return false\n }\n\n /**\n * Composes an object from the given array of keys and values.\n */\n public static zipObject(keys: any[], values: any[]): ObjectLiteral {\n return keys.reduce((object, column, index) => {\n object[column] = values[index]\n return object\n }, {} as ObjectLiteral)\n }\n\n /**\n * Compares two arrays.\n */\n public static isArraysEqual(arr1: any[], arr2: any[]): boolean {\n if (arr1.length !== arr2.length) return false\n return arr1.every((element) => {\n return arr2.indexOf(element) !== -1\n })\n }\n\n public static areMutuallyExclusive<T>(...lists: T[][]): boolean {\n const haveSharedObjects = lists.some((list) => {\n const otherLists = lists.filter((otherList) => otherList !== list)\n return list.some((item) =>\n otherLists.some((otherList) => otherList.includes(item)),\n )\n })\n return !haveSharedObjects\n }\n\n /**\n * Parses the CHECK constraint on the specified column and returns\n * all values allowed by the constraint or undefined if the constraint\n * is not present.\n */\n public static parseSqlCheckExpression(\n sql: string,\n columnName: string,\n ): string[] | undefined {\n const enumMatch = sql.match(\n new RegExp(\n `\"${columnName}\" varchar CHECK\\\\s*\\\\(\\\\s*\"${columnName}\"\\\\s+IN\\\\s*`,\n ),\n )\n\n if (enumMatch && enumMatch.index) {\n const afterMatch = sql.substring(\n enumMatch.index + enumMatch[0].length,\n )\n\n // This is an enum\n // all enum values stored as a comma separated list\n const chars = afterMatch\n\n /**\n * * When outside quotes: empty string\n * * When inside single quotes: `'`\n */\n let currentQuotes = \"\"\n let nextValue = \"\"\n const enumValues: string[] = []\n for (let idx = 0; idx < chars.length; idx++) {\n const char = chars[idx]\n switch (char) {\n case \",\":\n if (currentQuotes == \"\") {\n enumValues.push(nextValue)\n nextValue = \"\"\n } else {\n nextValue += char\n }\n break\n case \"'\":\n if (currentQuotes == char) {\n const isNextCharQuote = chars[idx + 1] === char\n if (isNextCharQuote) {\n // double quote in sql should be treated as a\n // single quote that's part of the quoted string\n nextValue += char\n idx += 1 // skip that next quote\n } else {\n currentQuotes = \"\"\n }\n } else {\n currentQuotes = char\n }\n break\n case \")\":\n if (currentQuotes == \"\") {\n enumValues.push(nextValue)\n return enumValues\n } else {\n nextValue += char\n }\n break\n default:\n if (currentQuotes != \"\") {\n nextValue += char\n }\n }\n }\n }\n return undefined\n }\n\n /**\n * Checks if given criteria is null or empty.\n */\n public static isCriteriaNullOrEmpty(criteria: unknown): boolean {\n return (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0) ||\n (this.isPlainObject(criteria) && Object.keys(criteria).length === 0)\n )\n }\n\n /**\n * Checks if given criteria is a primitive value.\n * Primitive values are strings, numbers and dates.\n */\n public static isSinglePrimitiveCriteria(\n criteria: unknown,\n ): criteria is SinglePrimitiveCriteria {\n return (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date\n )\n }\n\n /**\n * Checks if given criteria is a primitive value or an array of primitive values.\n */\n public static isPrimitiveCriteria(\n criteria: unknown,\n ): criteria is PrimitiveCriteria {\n if (Array.isArray(criteria)) {\n return criteria.every((value) =>\n this.isSinglePrimitiveCriteria(value),\n )\n }\n\n return this.isSinglePrimitiveCriteria(criteria)\n }\n\n // -------------------------------------------------------------------------\n // Private methods\n // -------------------------------------------------------------------------\n\n private static compare2Objects(\n leftChain: any,\n rightChain: any,\n x: any,\n y: any,\n ) {\n let p\n\n // remember that NaN === NaN returns false\n // and isNaN(undefined) returns true\n if (Number.isNaN(x) && Number.isNaN(y)) return true\n\n // Compare primitives and functions.\n // Check if both arguments link to the same object.\n // Especially useful on the step where we compare prototypes\n if (x === y) return true\n\n // Unequal, but either is null or undefined (use case: jsonb comparison)\n // PR #3776, todo: add tests\n if (x === null || y === null || x === undefined || y === undefined)\n return false\n\n // Fix the buffer compare bug.\n // See: https://github.com/typeorm/typeorm/issues/3654\n if (\n (typeof x.equals === \"function\" ||\n typeof x.equals === \"function\") &&\n x.equals(y)\n )\n return true\n\n // Works in case when functions are created in constructor.\n // Comparing dates is a common scenario. Another built-ins?\n // We can even handle functions passed across iframes\n if (\n (typeof x === \"function\" && typeof y === \"function\") ||\n (x instanceof Date && y instanceof Date) ||\n (x instanceof RegExp && y instanceof RegExp) ||\n (typeof x === \"string\" && typeof y === \"string\") ||\n (typeof x === \"number\" && typeof y === \"number\")\n )\n return x.toString() === y.toString()\n\n // At last checking prototypes as good as we can\n if (!(typeof x === \"object\" && typeof y === \"object\")) return false\n\n if (\n Object.prototype.isPrototypeOf.call(x, y) ||\n Object.prototype.isPrototypeOf.call(y, x)\n )\n return false\n\n if (x.constructor !== y.constructor) return false\n\n if (x.prototype !== y.prototype) return false\n\n // Check for infinitive linking loops\n if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1)\n return false\n\n // Quick checking of one object being a subset of another.\n // todo: cache the structure of arguments[0] for performance\n for (p in y) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n }\n\n for (p in x) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n\n switch (typeof x[p]) {\n case \"object\":\n case \"function\":\n leftChain.push(x)\n rightChain.push(y)\n\n if (\n !this.compare2Objects(leftChain, rightChain, x[p], y[p])\n ) {\n return false\n }\n\n leftChain.pop()\n rightChain.pop()\n break\n\n default:\n if (x[p] !== y[p]) {\n return false\n }\n break\n }\n }\n\n return true\n }\n\n // Checks if it's an object made by Object.create(null), {} or new Object()\n private static isPlainObject(item: any) {\n if (item === null || item === undefined) {\n return false\n }\n\n return !item.constructor || item.constructor === Object\n }\n\n private static mergeArrayKey(\n target: any,\n key: number,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n target[key] = memo.get(value)\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n target[key] = value\n return\n }\n\n if (!target[key]) {\n target[key] = Array.isArray(value) ? [] : {}\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static mergeObjectKey(\n target: any,\n key: string,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n Object.assign(target, { [key]: memo.get(value) })\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n Object.assign(target, { [key]: value })\n return\n }\n\n if (!target[key]) {\n Object.assign(target, { [key]: Array.isArray(value) ? [] : {} })\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static merge(\n target: any,\n source: any,\n memo: Map<any, any> = new Map(),\n ): any {\n if (this.isPlainObject(target) && this.isPlainObject(source)) {\n for (const key of Object.keys(source)) {\n if (key === \"__proto__\") continue\n this.mergeObjectKey(target, key, source[key], memo)\n }\n }\n\n if (Array.isArray(target) && Array.isArray(source)) {\n for (let key = 0; key < source.length; key++) {\n this.mergeArrayKey(target, key, source[key], memo)\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Driver } from "../driver/Driver";
|
|
2
|
+
interface BuildSqlTagParams {
|
|
3
|
+
driver: Driver;
|
|
4
|
+
strings: TemplateStringsArray;
|
|
5
|
+
expressions: unknown[];
|
|
6
|
+
}
|
|
7
|
+
export declare function buildSqlTag({ driver, strings, expressions, }: BuildSqlTagParams): {
|
|
8
|
+
query: string;
|
|
9
|
+
parameters: unknown[];
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import dedent from "dedent";
|
|
2
|
+
export function buildSqlTag({ driver, strings, expressions, }) {
|
|
3
|
+
let query = "";
|
|
4
|
+
const parameters = [];
|
|
5
|
+
let idx = 0;
|
|
6
|
+
for (const [expressionIdx, expression] of expressions.entries()) {
|
|
7
|
+
query += strings[expressionIdx];
|
|
8
|
+
if (expression === null) {
|
|
9
|
+
query += "NULL";
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (typeof expression === "function") {
|
|
13
|
+
const value = expression();
|
|
14
|
+
if (typeof value === "string") {
|
|
15
|
+
query += value;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
if (value.length === 0) {
|
|
20
|
+
throw new Error(`Expression ${expressionIdx} in this sql tagged template is a function which returned an empty array. Empty arrays cannot safely be expanded into parameter lists.`);
|
|
21
|
+
}
|
|
22
|
+
const arrayParams = value.map(() => {
|
|
23
|
+
return driver.createParameter(`param_${idx + 1}`, idx++);
|
|
24
|
+
});
|
|
25
|
+
query += arrayParams.join(", ");
|
|
26
|
+
parameters.push(...value);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Expression ${expressionIdx} in this sql tagged template is a function which returned a value of type "${value === null ? "null" : typeof value}". Only array and string types are supported as function return values in sql tagged template expressions.`);
|
|
30
|
+
}
|
|
31
|
+
query += driver.createParameter(`param_${idx + 1}`, idx++);
|
|
32
|
+
parameters.push(expression);
|
|
33
|
+
}
|
|
34
|
+
query += strings[strings.length - 1];
|
|
35
|
+
query = dedent(query);
|
|
36
|
+
return { query, parameters };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=SqlTagUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../browser/src/util/SqlTagUtils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAQ3B,MAAM,UAAU,WAAW,CAAC,EACxB,MAAM,EACN,OAAO,EACP,WAAW,GACK;IAChB,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,MAAM,UAAU,GAAc,EAAE,CAAA;IAChC,IAAI,GAAG,GAAG,CAAC,CAAA;IAEX,KAAK,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9D,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC,CAAA;QAE/B,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACtB,KAAK,IAAI,MAAM,CAAA;YACf,SAAQ;QACZ,CAAC;QAED,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,UAAU,EAAE,CAAA;YAE1B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,KAAK,IAAI,KAAK,CAAA;gBACd,SAAQ;YACZ,CAAC;YAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACrB,MAAM,IAAI,KAAK,CACX,cAAc,aAAa,wIAAwI,CACtK,CAAA;gBACL,CAAC;gBAED,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;oBAC/B,OAAO,MAAM,CAAC,eAAe,CAAC,SAAS,GAAG,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;gBAC5D,CAAC,CAAC,CAAA;gBAEF,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBAC/B,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;gBAEzB,SAAQ;YACZ,CAAC;YAED,MAAM,IAAI,KAAK,CACX,cAAc,aAAa,8EACvB,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KACrC,4GAA4G,CAC/G,CAAA;QACL,CAAC;QAED,KAAK,IAAI,MAAM,CAAC,eAAe,CAAC,SAAS,GAAG,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QAE1D,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC/B,CAAC;IAED,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAEpC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAErB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA;AAChC,CAAC","file":"SqlTagUtils.js","sourcesContent":["import { Driver } from \"../driver/Driver\"\nimport dedent from \"dedent\"\n\ninterface BuildSqlTagParams {\n driver: Driver\n strings: TemplateStringsArray\n expressions: unknown[]\n}\n\nexport function buildSqlTag({\n driver,\n strings,\n expressions,\n}: BuildSqlTagParams): { query: string; parameters: unknown[] } {\n let query = \"\"\n const parameters: unknown[] = []\n let idx = 0\n\n for (const [expressionIdx, expression] of expressions.entries()) {\n query += strings[expressionIdx]\n\n if (expression === null) {\n query += \"NULL\"\n continue\n }\n\n if (typeof expression === \"function\") {\n const value = expression()\n\n if (typeof value === \"string\") {\n query += value\n continue\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n throw new Error(\n `Expression ${expressionIdx} in this sql tagged template is a function which returned an empty array. Empty arrays cannot safely be expanded into parameter lists.`,\n )\n }\n\n const arrayParams = value.map(() => {\n return driver.createParameter(`param_${idx + 1}`, idx++)\n })\n\n query += arrayParams.join(\", \")\n parameters.push(...value)\n\n continue\n }\n\n throw new Error(\n `Expression ${expressionIdx} in this sql tagged template is a function which returned a value of type \"${\n value === null ? \"null\" : typeof value\n }\". Only array and string types are supported as function return values in sql tagged template expressions.`,\n )\n }\n\n query += driver.createParameter(`param_${idx + 1}`, idx++)\n\n parameters.push(expression)\n }\n\n query += strings[strings.length - 1]\n\n query = dedent(query)\n\n return { query, parameters }\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/PrimitiveCriteria.ts"],"names":[],"mappings":"","file":"PrimitiveCriteria.js","sourcesContent":["export type SinglePrimitiveCriteria = string | number | Date\n\nexport type PrimitiveCriteria =\n | SinglePrimitiveCriteria\n | SinglePrimitiveCriteria[]\n"],"sourceRoot":".."}
|
|
@@ -63,7 +63,7 @@ export interface BaseDataSourceOptions {
|
|
|
63
63
|
/**
|
|
64
64
|
* Logger instance used to log queries and events in the ORM.
|
|
65
65
|
*/
|
|
66
|
-
readonly logger?: "advanced-console" | "simple-console" | "file" | "debug" | Logger;
|
|
66
|
+
readonly logger?: "advanced-console" | "simple-console" | "formatted-console" | "file" | "debug" | Logger;
|
|
67
67
|
/**
|
|
68
68
|
* Maximum number of milliseconds query should be executed before logger log a warning.
|
|
69
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","file":"BaseDataSourceOptions.js","sourcesContent":["import { EntitySchema } from \"../entity-schema/EntitySchema\"\nimport { LoggerOptions } from \"../logger/LoggerOptions\"\nimport { NamingStrategyInterface } from \"../naming-strategy/NamingStrategyInterface\"\nimport { DatabaseType } from \"../driver/types/DatabaseType\"\nimport { Logger } from \"../logger/Logger\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { MixedList } from \"../common/MixedList\"\n\n/**\n * BaseDataSourceOptions is set of DataSourceOptions shared by all database types.\n */\nexport interface BaseDataSourceOptions {\n /**\n * Database type. This value is required.\n */\n readonly type: DatabaseType\n\n /**\n * Connection name. If connection name is not given then it will be called \"default\".\n * Different connections must have different names.\n *\n * @deprecated\n */\n readonly name?: string\n\n /**\n * Entities to be loaded for this connection.\n * Accepts both entity classes and directories where from entities need to be loaded.\n * Directories support glob patterns.\n */\n readonly entities?: MixedList<Function | string | EntitySchema>\n\n /**\n * Subscribers to be loaded for this connection.\n * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n * Directories support glob patterns.\n */\n readonly subscribers?: MixedList<Function | string>\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and glob patterns representing migration files.\n */\n readonly migrations?: MixedList<Function | string>\n\n /**\n * Migrations table name, in case of different name from \"migrations\".\n * Accepts single string name.\n */\n readonly migrationsTableName?: string\n\n /**\n * Transaction mode for migrations to run in\n */\n readonly migrationsTransactionMode?: \"all\" | \"none\" | \"each\"\n\n /**\n * Typeorm metadata table name, in case of different name from \"typeorm_metadata\".\n * Accepts single string name.\n */\n readonly metadataTableName?: string\n\n /**\n * Naming strategy to be used to name tables and columns in the database.\n */\n readonly namingStrategy?: NamingStrategyInterface\n\n /**\n * Logging options.\n */\n readonly logging?: LoggerOptions\n\n /**\n * Logger instance used to log queries and events in the ORM.\n */\n readonly logger?:\n | \"advanced-console\"\n | \"simple-console\"\n | \"file\"\n | \"debug\"\n | Logger\n\n /**\n * Maximum number of milliseconds query should be executed before logger log a warning.\n */\n readonly maxQueryExecutionTime?: number\n\n /**\n * Maximum number of clients the pool should contain.\n */\n readonly poolSize?: number\n\n /**\n * Indicates if database schema should be auto created on every application launch.\n * Be careful with this option and don't use this in production - otherwise you can lose production data.\n * This option is useful during debug and development.\n * Alternative to it, you can use CLI and run schema:sync command.\n *\n * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n * Instead, it syncs just by creating indices.\n */\n readonly synchronize?: boolean\n\n /**\n * Indicates if migrations should be auto run on every application launch.\n * Alternative to it, you can use CLI and run migrations:run command.\n */\n readonly migrationsRun?: boolean\n\n /**\n * Drops the schema each time connection is being established.\n * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n * This option is useful during debug and development.\n */\n readonly dropSchema?: boolean\n\n /**\n * Prefix to use on all tables (collections) of this connection in the database.\n */\n readonly entityPrefix?: string\n\n /**\n * When creating new Entity instances, skip all constructors when true.\n */\n readonly entitySkipConstructor?: boolean\n\n /**\n * Extra connection options to be passed to the underlying driver.\n *\n * todo: deprecate this and move all database-specific types into hts own connection options object.\n */\n readonly extra?: any\n\n /**\n * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but this default can be changed here.\n * Also, strategy can be set per-query in FindOptions and QueryBuilder.\n */\n readonly relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Optionally applied \"typename\" to the model.\n * If set, then each hydrated model will have this property with the target model / entity name inside.\n *\n * (works like a discriminator property).\n */\n readonly typename?: string\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected.\n *\n * @internal\n */\n baseDirectory?: string\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?:\n | boolean\n | {\n /**\n * Type of caching.\n *\n * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n */\n readonly type?:\n | \"database\"\n | \"redis\"\n | \"ioredis\"\n | \"ioredis/cluster\" // todo: add mongodb and other cache providers as well in the future\n\n /**\n * Factory function for custom cache providers that implement QueryResultCache.\n */\n readonly provider?: (connection: DataSource) => QueryResultCache\n\n /**\n * Configurable table name for \"database\" type cache.\n * Default value is \"query-result-cache\"\n */\n readonly tableName?: string\n\n /**\n * Used to provide redis connection options.\n */\n readonly options?: any\n\n /**\n * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n */\n readonly alwaysEnabled?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * This can be setup per-query.\n * Default value is 1000 which is equivalent to 1 second.\n */\n readonly duration?: number\n\n /**\n * Used to specify if cache errors should be ignored, and pass through the call to the Database.\n */\n readonly ignoreErrors?: boolean\n }\n\n /**\n * Allows automatic isolation of where clauses\n */\n readonly isolateWhereStatements?: boolean\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","file":"BaseDataSourceOptions.js","sourcesContent":["import { EntitySchema } from \"../entity-schema/EntitySchema\"\nimport { LoggerOptions } from \"../logger/LoggerOptions\"\nimport { NamingStrategyInterface } from \"../naming-strategy/NamingStrategyInterface\"\nimport { DatabaseType } from \"../driver/types/DatabaseType\"\nimport { Logger } from \"../logger/Logger\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { MixedList } from \"../common/MixedList\"\n\n/**\n * BaseDataSourceOptions is set of DataSourceOptions shared by all database types.\n */\nexport interface BaseDataSourceOptions {\n /**\n * Database type. This value is required.\n */\n readonly type: DatabaseType\n\n /**\n * Connection name. If connection name is not given then it will be called \"default\".\n * Different connections must have different names.\n *\n * @deprecated\n */\n readonly name?: string\n\n /**\n * Entities to be loaded for this connection.\n * Accepts both entity classes and directories where from entities need to be loaded.\n * Directories support glob patterns.\n */\n readonly entities?: MixedList<Function | string | EntitySchema>\n\n /**\n * Subscribers to be loaded for this connection.\n * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n * Directories support glob patterns.\n */\n readonly subscribers?: MixedList<Function | string>\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and glob patterns representing migration files.\n */\n readonly migrations?: MixedList<Function | string>\n\n /**\n * Migrations table name, in case of different name from \"migrations\".\n * Accepts single string name.\n */\n readonly migrationsTableName?: string\n\n /**\n * Transaction mode for migrations to run in\n */\n readonly migrationsTransactionMode?: \"all\" | \"none\" | \"each\"\n\n /**\n * Typeorm metadata table name, in case of different name from \"typeorm_metadata\".\n * Accepts single string name.\n */\n readonly metadataTableName?: string\n\n /**\n * Naming strategy to be used to name tables and columns in the database.\n */\n readonly namingStrategy?: NamingStrategyInterface\n\n /**\n * Logging options.\n */\n readonly logging?: LoggerOptions\n\n /**\n * Logger instance used to log queries and events in the ORM.\n */\n readonly logger?:\n | \"advanced-console\"\n | \"simple-console\"\n | \"formatted-console\"\n | \"file\"\n | \"debug\"\n | Logger\n\n /**\n * Maximum number of milliseconds query should be executed before logger log a warning.\n */\n readonly maxQueryExecutionTime?: number\n\n /**\n * Maximum number of clients the pool should contain.\n */\n readonly poolSize?: number\n\n /**\n * Indicates if database schema should be auto created on every application launch.\n * Be careful with this option and don't use this in production - otherwise you can lose production data.\n * This option is useful during debug and development.\n * Alternative to it, you can use CLI and run schema:sync command.\n *\n * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n * Instead, it syncs just by creating indices.\n */\n readonly synchronize?: boolean\n\n /**\n * Indicates if migrations should be auto run on every application launch.\n * Alternative to it, you can use CLI and run migrations:run command.\n */\n readonly migrationsRun?: boolean\n\n /**\n * Drops the schema each time connection is being established.\n * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n * This option is useful during debug and development.\n */\n readonly dropSchema?: boolean\n\n /**\n * Prefix to use on all tables (collections) of this connection in the database.\n */\n readonly entityPrefix?: string\n\n /**\n * When creating new Entity instances, skip all constructors when true.\n */\n readonly entitySkipConstructor?: boolean\n\n /**\n * Extra connection options to be passed to the underlying driver.\n *\n * todo: deprecate this and move all database-specific types into hts own connection options object.\n */\n readonly extra?: any\n\n /**\n * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but this default can be changed here.\n * Also, strategy can be set per-query in FindOptions and QueryBuilder.\n */\n readonly relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Optionally applied \"typename\" to the model.\n * If set, then each hydrated model will have this property with the target model / entity name inside.\n *\n * (works like a discriminator property).\n */\n readonly typename?: string\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected.\n *\n * @internal\n */\n baseDirectory?: string\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?:\n | boolean\n | {\n /**\n * Type of caching.\n *\n * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n */\n readonly type?:\n | \"database\"\n | \"redis\"\n | \"ioredis\"\n | \"ioredis/cluster\" // todo: add mongodb and other cache providers as well in the future\n\n /**\n * Factory function for custom cache providers that implement QueryResultCache.\n */\n readonly provider?: (connection: DataSource) => QueryResultCache\n\n /**\n * Configurable table name for \"database\" type cache.\n * Default value is \"query-result-cache\"\n */\n readonly tableName?: string\n\n /**\n * Used to provide redis connection options.\n */\n readonly options?: any\n\n /**\n * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n */\n readonly alwaysEnabled?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * This can be setup per-query.\n * Default value is 1000 which is equivalent to 1 second.\n */\n readonly duration?: number\n\n /**\n * Used to specify if cache errors should be ignored, and pass through the call to the Database.\n */\n readonly ignoreErrors?: boolean\n }\n\n /**\n * Allows automatic isolation of where clauses\n */\n readonly isolateWhereStatements?: boolean\n}\n"],"sourceRoot":".."}
|
|
@@ -218,6 +218,14 @@ export declare class DataSource {
|
|
|
218
218
|
* @see [Official docs](https://typeorm.io/data-source-api) for examples.
|
|
219
219
|
*/
|
|
220
220
|
query<T = any>(query: string, parameters?: any[], queryRunner?: QueryRunner): Promise<T>;
|
|
221
|
+
/**
|
|
222
|
+
* Tagged template function that executes raw SQL query and returns raw database results.
|
|
223
|
+
* Template expressions are automatically transformed into database parameters.
|
|
224
|
+
* Raw query execution is supported only by relational databases (MongoDB is not supported).
|
|
225
|
+
* Note: Don't call this as a regular function, it is meant to be used with backticks to tag a template literal.
|
|
226
|
+
* Example: dataSource.sql`SELECT * FROM table_name WHERE id = ${id}`
|
|
227
|
+
*/
|
|
228
|
+
sql<T = any>(strings: TemplateStringsArray, ...values: unknown[]): Promise<T>;
|
|
221
229
|
/**
|
|
222
230
|
* Creates a new query builder that can be used to build a SQL query.
|
|
223
231
|
*/
|
|
@@ -17,6 +17,7 @@ const ObjectUtils_1 = require("../util/ObjectUtils");
|
|
|
17
17
|
const RelationIdLoader_1 = require("../query-builder/RelationIdLoader");
|
|
18
18
|
const DriverUtils_1 = require("../driver/DriverUtils");
|
|
19
19
|
const InstanceChecker_1 = require("../util/InstanceChecker");
|
|
20
|
+
const SqlTagUtils_1 = require("../util/SqlTagUtils");
|
|
20
21
|
(0, query_builder_1.registerQueryBuilders)();
|
|
21
22
|
/**
|
|
22
23
|
* DataSource is a pre-defined connection configuration to a specific database.
|
|
@@ -356,6 +357,21 @@ class DataSource {
|
|
|
356
357
|
await usedQueryRunner.release();
|
|
357
358
|
}
|
|
358
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Tagged template function that executes raw SQL query and returns raw database results.
|
|
362
|
+
* Template expressions are automatically transformed into database parameters.
|
|
363
|
+
* Raw query execution is supported only by relational databases (MongoDB is not supported).
|
|
364
|
+
* Note: Don't call this as a regular function, it is meant to be used with backticks to tag a template literal.
|
|
365
|
+
* Example: dataSource.sql`SELECT * FROM table_name WHERE id = ${id}`
|
|
366
|
+
*/
|
|
367
|
+
async sql(strings, ...values) {
|
|
368
|
+
const { query, parameters } = (0, SqlTagUtils_1.buildSqlTag)({
|
|
369
|
+
driver: this.driver,
|
|
370
|
+
strings: strings,
|
|
371
|
+
expressions: values,
|
|
372
|
+
});
|
|
373
|
+
return await this.query(query, parameters);
|
|
374
|
+
}
|
|
359
375
|
/**
|
|
360
376
|
* Creates a new query builder that can be used to build a SQL query.
|
|
361
377
|
*/
|
|
@@ -486,7 +502,8 @@ class DataSource {
|
|
|
486
502
|
* Get the replication mode SELECT queries should use for this datasource by default
|
|
487
503
|
*/
|
|
488
504
|
defaultReplicationModeForReads() {
|
|
489
|
-
if ("replication" in this.driver.options
|
|
505
|
+
if ("replication" in this.driver.options &&
|
|
506
|
+
this.driver.options.replication) {
|
|
490
507
|
const value = this.driver.options.replication.defaultMode;
|
|
491
508
|
if (value) {
|
|
492
509
|
return value;
|