@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.100
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/EntityManager.d.ts +96 -58
- package/EntityManager.js +465 -395
- package/MikroORM.d.ts +45 -35
- package/MikroORM.js +109 -160
- package/README.md +3 -2
- package/cache/CacheAdapter.js +1 -2
- package/cache/FileCacheAdapter.d.ts +2 -2
- package/cache/FileCacheAdapter.js +20 -27
- package/cache/GeneratedCacheAdapter.d.ts +2 -3
- package/cache/GeneratedCacheAdapter.js +1 -7
- package/cache/MemoryCacheAdapter.d.ts +1 -1
- package/cache/MemoryCacheAdapter.js +1 -5
- package/cache/NullCacheAdapter.d.ts +1 -1
- package/cache/NullCacheAdapter.js +1 -5
- package/cache/index.d.ts +4 -5
- package/cache/index.js +4 -21
- package/connections/Connection.d.ts +22 -14
- package/connections/Connection.js +27 -23
- package/connections/index.d.ts +1 -1
- package/connections/index.js +1 -17
- package/drivers/DatabaseDriver.d.ts +25 -15
- package/drivers/DatabaseDriver.js +77 -64
- package/drivers/IDatabaseDriver.d.ts +40 -16
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/BaseEntity.d.ts +6 -7
- package/entity/BaseEntity.js +16 -23
- package/entity/Collection.d.ts +98 -34
- package/entity/Collection.js +466 -131
- package/entity/EntityAssigner.d.ts +3 -3
- package/entity/EntityAssigner.js +67 -64
- package/entity/EntityFactory.d.ts +10 -3
- package/entity/EntityFactory.js +112 -91
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +66 -53
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityIdentifier.js +1 -5
- package/entity/EntityLoader.d.ts +8 -7
- package/entity/EntityLoader.js +161 -128
- package/entity/EntityRepository.d.ts +8 -8
- package/entity/EntityRepository.js +7 -11
- package/entity/Reference.d.ts +10 -13
- package/entity/Reference.js +64 -46
- package/entity/WrappedEntity.d.ts +12 -17
- package/entity/WrappedEntity.js +22 -31
- package/entity/defineEntity.d.ts +568 -0
- package/entity/defineEntity.js +529 -0
- package/entity/index.d.ts +14 -13
- package/entity/index.js +14 -29
- package/entity/utils.d.ts +8 -1
- package/entity/utils.js +22 -13
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/entity/wrap.d.ts +1 -1
- package/entity/wrap.js +2 -6
- package/enums.d.ts +24 -9
- package/enums.js +50 -41
- package/errors.d.ts +11 -3
- package/errors.js +42 -32
- package/events/EventManager.d.ts +5 -4
- package/events/EventManager.js +26 -22
- package/events/EventSubscriber.d.ts +8 -5
- package/events/EventSubscriber.js +1 -2
- package/events/TransactionEventBroadcaster.d.ts +3 -3
- package/events/TransactionEventBroadcaster.js +1 -5
- package/events/index.d.ts +3 -3
- package/events/index.js +3 -19
- package/exceptions.js +18 -39
- package/hydration/Hydrator.d.ts +5 -5
- package/hydration/Hydrator.js +2 -6
- package/hydration/ObjectHydrator.d.ts +7 -7
- package/hydration/ObjectHydrator.js +58 -50
- package/hydration/index.d.ts +2 -2
- package/hydration/index.js +2 -18
- package/index.d.ts +21 -21
- package/index.js +20 -46
- package/logging/DefaultLogger.d.ts +2 -2
- package/logging/DefaultLogger.js +10 -13
- package/logging/Logger.d.ts +1 -1
- package/logging/Logger.js +1 -2
- package/logging/SimpleLogger.d.ts +3 -3
- package/logging/SimpleLogger.js +2 -6
- package/logging/colors.js +1 -5
- package/logging/index.d.ts +5 -4
- package/logging/index.js +5 -20
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +16 -0
- package/metadata/EntitySchema.d.ts +14 -10
- package/metadata/EntitySchema.js +78 -64
- package/metadata/MetadataDiscovery.d.ts +11 -14
- package/metadata/MetadataDiscovery.js +278 -317
- package/metadata/MetadataProvider.d.ts +13 -4
- package/metadata/MetadataProvider.js +47 -8
- package/metadata/MetadataStorage.d.ts +2 -7
- package/metadata/MetadataStorage.js +19 -35
- package/metadata/MetadataValidator.d.ts +3 -10
- package/metadata/MetadataValidator.js +51 -64
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +6 -6
- package/metadata/index.js +6 -22
- package/metadata/types.d.ts +480 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +7 -3
- package/naming-strategy/AbstractNamingStrategy.js +11 -9
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
- package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
- package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
- package/naming-strategy/MongoNamingStrategy.js +2 -6
- package/naming-strategy/NamingStrategy.d.ts +12 -2
- package/naming-strategy/NamingStrategy.js +1 -2
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
- package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
- package/naming-strategy/index.d.ts +5 -5
- package/naming-strategy/index.js +5 -21
- package/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +19 -20
- package/platforms/ExceptionConverter.d.ts +2 -2
- package/platforms/ExceptionConverter.js +4 -8
- package/platforms/Platform.d.ts +15 -22
- package/platforms/Platform.js +58 -88
- package/platforms/index.d.ts +2 -2
- package/platforms/index.js +2 -18
- package/serialization/EntitySerializer.d.ts +4 -2
- package/serialization/EntitySerializer.js +64 -51
- package/serialization/EntityTransformer.d.ts +1 -1
- package/serialization/EntityTransformer.js +48 -42
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +24 -25
- package/serialization/index.d.ts +3 -3
- package/serialization/index.js +3 -19
- package/types/ArrayType.d.ts +3 -3
- package/types/ArrayType.js +6 -11
- package/types/BigIntType.d.ts +12 -9
- package/types/BigIntType.js +6 -6
- package/types/BlobType.d.ts +3 -4
- package/types/BlobType.js +2 -11
- package/types/BooleanType.d.ts +5 -4
- package/types/BooleanType.js +5 -6
- package/types/CharacterType.d.ts +3 -3
- package/types/CharacterType.js +2 -6
- package/types/DateTimeType.d.ts +3 -3
- package/types/DateTimeType.js +2 -6
- package/types/DateType.d.ts +3 -3
- package/types/DateType.js +2 -6
- package/types/DecimalType.d.ts +9 -7
- package/types/DecimalType.js +5 -8
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +4 -7
- package/types/EnumArrayType.d.ts +4 -4
- package/types/EnumArrayType.js +4 -10
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +2 -6
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +2 -6
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +2 -6
- package/types/IntervalType.d.ts +3 -3
- package/types/IntervalType.js +2 -6
- package/types/JsonType.d.ts +4 -4
- package/types/JsonType.js +9 -8
- package/types/MediumIntType.d.ts +3 -3
- package/types/MediumIntType.js +2 -6
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +2 -6
- package/types/StringType.d.ts +3 -3
- package/types/StringType.js +2 -6
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +2 -6
- package/types/TimeType.d.ts +3 -3
- package/types/TimeType.js +4 -8
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +3 -6
- package/types/Type.d.ts +4 -6
- package/types/Type.js +6 -10
- package/types/Uint8ArrayType.d.ts +3 -4
- package/types/Uint8ArrayType.js +3 -12
- package/types/UnknownType.d.ts +3 -3
- package/types/UnknownType.js +2 -6
- package/types/UuidType.d.ts +3 -3
- package/types/UuidType.js +2 -6
- package/types/index.d.ts +25 -25
- package/types/index.js +52 -79
- package/typings.d.ts +134 -93
- package/typings.js +67 -65
- package/unit-of-work/ChangeSet.d.ts +1 -4
- package/unit-of-work/ChangeSet.js +13 -17
- package/unit-of-work/ChangeSetComputer.d.ts +8 -9
- package/unit-of-work/ChangeSetComputer.js +36 -38
- package/unit-of-work/ChangeSetPersister.d.ts +11 -9
- package/unit-of-work/ChangeSetPersister.js +100 -65
- package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
- package/unit-of-work/CommitOrderCalculator.js +6 -10
- package/unit-of-work/IdentityMap.d.ts +1 -1
- package/unit-of-work/IdentityMap.js +1 -5
- package/unit-of-work/UnitOfWork.d.ts +16 -8
- package/unit-of-work/UnitOfWork.js +266 -209
- package/unit-of-work/index.d.ts +6 -6
- package/unit-of-work/index.js +6 -22
- package/utils/AbstractSchemaGenerator.d.ts +11 -11
- package/utils/AbstractSchemaGenerator.js +21 -20
- package/utils/Configuration.d.ts +774 -224
- package/utils/Configuration.js +166 -216
- package/utils/ConfigurationLoader.d.ts +1 -53
- package/utils/ConfigurationLoader.js +1 -367
- package/utils/Cursor.d.ts +6 -9
- package/utils/Cursor.js +25 -25
- package/utils/DataloaderUtils.d.ts +18 -8
- package/utils/DataloaderUtils.js +63 -21
- package/utils/EntityComparator.d.ts +9 -5
- package/utils/EntityComparator.js +155 -108
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +1 -5
- package/utils/QueryHelper.d.ts +12 -4
- package/utils/QueryHelper.js +110 -53
- package/utils/RawQueryFragment.d.ts +37 -14
- package/utils/RawQueryFragment.js +50 -33
- package/utils/RequestContext.d.ts +2 -2
- package/utils/RequestContext.js +3 -7
- package/utils/TransactionContext.d.ts +1 -1
- package/utils/TransactionContext.js +4 -8
- package/utils/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +223 -0
- package/utils/Utils.d.ts +16 -100
- package/utils/Utils.js +114 -332
- package/utils/clone.js +7 -11
- package/utils/env-vars.d.ts +3 -0
- package/utils/env-vars.js +87 -0
- package/utils/fs-utils.d.ts +12 -0
- package/utils/fs-utils.js +97 -0
- package/utils/index.d.ts +14 -13
- package/utils/index.js +14 -29
- package/utils/upsert-utils.d.ts +8 -3
- package/utils/upsert-utils.js +57 -10
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -16
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -33
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -14
- package/decorators/Embedded.d.ts +0 -18
- package/decorators/Embedded.js +0 -20
- package/decorators/Entity.d.ts +0 -18
- package/decorators/Entity.js +0 -16
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -19
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -11
- package/decorators/Formula.d.ts +0 -5
- package/decorators/Formula.js +0 -18
- package/decorators/Indexed.d.ts +0 -17
- package/decorators/Indexed.js +0 -24
- package/decorators/ManyToMany.d.ts +0 -40
- package/decorators/ManyToMany.js +0 -16
- package/decorators/ManyToOne.d.ts +0 -30
- package/decorators/ManyToOne.js +0 -16
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -20
- package/decorators/OneToOne.d.ts +0 -24
- package/decorators/OneToOne.js +0 -10
- package/decorators/PrimaryKey.d.ts +0 -9
- package/decorators/PrimaryKey.js +0 -23
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -34
- package/decorators/Transactional.d.ts +0 -13
- package/decorators/Transactional.js +0 -31
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -59
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -36
- package/entity/ArrayCollection.d.ts +0 -116
- package/entity/ArrayCollection.js +0 -399
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -154
- package/index.mjs +0 -199
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -48
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -31
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const JsonType_1 = require("../types/JsonType");
|
|
8
|
-
const RawQueryFragment_1 = require("./RawQueryFragment");
|
|
9
|
-
class EntityComparator {
|
|
1
|
+
import { clone } from './clone.js';
|
|
2
|
+
import { ReferenceKind } from '../enums.js';
|
|
3
|
+
import { compareArrays, compareBooleans, compareBuffers, compareObjects, equals, parseJsonSafe, Utils } from './Utils.js';
|
|
4
|
+
import { JsonType } from '../types/JsonType.js';
|
|
5
|
+
import { RawQueryFragment } from './RawQueryFragment.js';
|
|
6
|
+
export class EntityComparator {
|
|
10
7
|
metadata;
|
|
11
8
|
platform;
|
|
12
9
|
comparators = new Map();
|
|
@@ -23,13 +20,13 @@ class EntityComparator {
|
|
|
23
20
|
/**
|
|
24
21
|
* Computes difference between two entities.
|
|
25
22
|
*/
|
|
26
|
-
diffEntities(entityName, a, b) {
|
|
23
|
+
diffEntities(entityName, a, b, options) {
|
|
27
24
|
const comparator = this.getEntityComparator(entityName);
|
|
28
|
-
return
|
|
25
|
+
return Utils.callCompiledFunction(comparator, a, b, options);
|
|
29
26
|
}
|
|
30
27
|
matching(entityName, a, b) {
|
|
31
28
|
const diff = this.diffEntities(entityName, a, b);
|
|
32
|
-
return
|
|
29
|
+
return Utils.getObjectKeysSize(diff) === 0;
|
|
33
30
|
}
|
|
34
31
|
/**
|
|
35
32
|
* Removes ORM specific code from entities and prepares it for serializing. Used before change set computation.
|
|
@@ -37,21 +34,21 @@ class EntityComparator {
|
|
|
37
34
|
*/
|
|
38
35
|
prepareEntity(entity) {
|
|
39
36
|
const generator = this.getSnapshotGenerator(entity.constructor.name);
|
|
40
|
-
return
|
|
37
|
+
return Utils.callCompiledFunction(generator, entity);
|
|
41
38
|
}
|
|
42
39
|
/**
|
|
43
40
|
* Maps database columns to properties.
|
|
44
41
|
*/
|
|
45
42
|
mapResult(entityName, result) {
|
|
46
43
|
const mapper = this.getResultMapper(entityName);
|
|
47
|
-
return
|
|
44
|
+
return Utils.callCompiledFunction(mapper, result);
|
|
48
45
|
}
|
|
49
46
|
/**
|
|
50
47
|
* @internal Highly performance-sensitive method.
|
|
51
48
|
*/
|
|
52
49
|
getPkGetter(meta) {
|
|
53
50
|
const exists = this.pkGetters.get(meta.className);
|
|
54
|
-
/*
|
|
51
|
+
/* v8 ignore next */
|
|
55
52
|
if (exists) {
|
|
56
53
|
return exists;
|
|
57
54
|
}
|
|
@@ -60,7 +57,7 @@ class EntityComparator {
|
|
|
60
57
|
if (meta.primaryKeys.length > 1) {
|
|
61
58
|
lines.push(` const cond = {`);
|
|
62
59
|
meta.primaryKeys.forEach(pk => {
|
|
63
|
-
if (meta.properties[pk].kind !==
|
|
60
|
+
if (meta.properties[pk].kind !== ReferenceKind.SCALAR) {
|
|
64
61
|
lines.push(` ${pk}: (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference)) ? entity${this.wrap(pk)}.__helper.getPrimaryKey() : entity${this.wrap(pk)},`);
|
|
65
62
|
}
|
|
66
63
|
else {
|
|
@@ -73,11 +70,11 @@ class EntityComparator {
|
|
|
73
70
|
}
|
|
74
71
|
else {
|
|
75
72
|
const pk = meta.primaryKeys[0];
|
|
76
|
-
if (meta.properties[pk].kind !==
|
|
73
|
+
if (meta.properties[pk].kind !== ReferenceKind.SCALAR) {
|
|
77
74
|
lines.push(` if (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference)) {`);
|
|
78
75
|
lines.push(` const pk = entity${this.wrap(pk)}.__helper.getPrimaryKey();`);
|
|
79
76
|
if (meta.properties[pk].targetMeta.compositePK) {
|
|
80
|
-
lines.push(` if (typeof pk === 'object') {`);
|
|
77
|
+
lines.push(` if (typeof pk === 'object' && pk != null) {`);
|
|
81
78
|
lines.push(` return [`);
|
|
82
79
|
for (const childPK of meta.properties[pk].targetMeta.primaryKeys) {
|
|
83
80
|
lines.push(` pk${this.wrap(childPK)},`);
|
|
@@ -92,7 +89,7 @@ class EntityComparator {
|
|
|
92
89
|
}
|
|
93
90
|
const code = `// compiled pk serializer for entity ${meta.className}\n`
|
|
94
91
|
+ `return function(entity) {\n${lines.join('\n')}\n}`;
|
|
95
|
-
const pkSerializer =
|
|
92
|
+
const pkSerializer = Utils.createFunction(context, code);
|
|
96
93
|
this.pkGetters.set(meta.className, pkSerializer);
|
|
97
94
|
return pkSerializer;
|
|
98
95
|
}
|
|
@@ -101,7 +98,7 @@ class EntityComparator {
|
|
|
101
98
|
*/
|
|
102
99
|
getPkGetterConverted(meta) {
|
|
103
100
|
const exists = this.pkGettersConverted.get(meta.className);
|
|
104
|
-
/*
|
|
101
|
+
/* v8 ignore next */
|
|
105
102
|
if (exists) {
|
|
106
103
|
return exists;
|
|
107
104
|
}
|
|
@@ -110,7 +107,7 @@ class EntityComparator {
|
|
|
110
107
|
if (meta.primaryKeys.length > 1) {
|
|
111
108
|
lines.push(` const cond = {`);
|
|
112
109
|
meta.primaryKeys.forEach(pk => {
|
|
113
|
-
if (meta.properties[pk].kind !==
|
|
110
|
+
if (meta.properties[pk].kind !== ReferenceKind.SCALAR) {
|
|
114
111
|
lines.push(` ${pk}: (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference)) ? entity${this.wrap(pk)}.__helper.getPrimaryKey(true) : entity${this.wrap(pk)},`);
|
|
115
112
|
}
|
|
116
113
|
else {
|
|
@@ -129,7 +126,7 @@ class EntityComparator {
|
|
|
129
126
|
}
|
|
130
127
|
else {
|
|
131
128
|
const pk = meta.primaryKeys[0];
|
|
132
|
-
if (meta.properties[pk].kind !==
|
|
129
|
+
if (meta.properties[pk].kind !== ReferenceKind.SCALAR) {
|
|
133
130
|
lines.push(` if (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference)) return entity${this.wrap(pk)}.__helper.getPrimaryKey(true);`);
|
|
134
131
|
}
|
|
135
132
|
if (meta.properties[pk].customType) {
|
|
@@ -142,7 +139,7 @@ class EntityComparator {
|
|
|
142
139
|
}
|
|
143
140
|
const code = `// compiled pk getter (with converted custom types) for entity ${meta.className}\n`
|
|
144
141
|
+ `return function(entity) {\n${lines.join('\n')}\n}`;
|
|
145
|
-
const pkSerializer =
|
|
142
|
+
const pkSerializer = Utils.createFunction(context, code);
|
|
146
143
|
this.pkGettersConverted.set(meta.className, pkSerializer);
|
|
147
144
|
return pkSerializer;
|
|
148
145
|
}
|
|
@@ -151,17 +148,18 @@ class EntityComparator {
|
|
|
151
148
|
*/
|
|
152
149
|
getPkSerializer(meta) {
|
|
153
150
|
const exists = this.pkSerializers.get(meta.className);
|
|
154
|
-
/*
|
|
151
|
+
/* v8 ignore next */
|
|
155
152
|
if (exists) {
|
|
156
153
|
return exists;
|
|
157
154
|
}
|
|
158
155
|
const lines = [];
|
|
159
156
|
const context = new Map();
|
|
160
|
-
context.set('getCompositeKeyValue', (val) =>
|
|
157
|
+
context.set('getCompositeKeyValue', (val) => Utils.flatten(Utils.getCompositeKeyValue(val, meta, 'convertToDatabaseValue', this.platform)));
|
|
158
|
+
context.set('getPrimaryKeyHash', (val) => Utils.getPrimaryKeyHash(Utils.asArray(val)));
|
|
161
159
|
if (meta.primaryKeys.length > 1) {
|
|
162
160
|
lines.push(` const pks = entity.__helper.__pk ? getCompositeKeyValue(entity.__helper.__pk) : [`);
|
|
163
161
|
meta.primaryKeys.forEach(pk => {
|
|
164
|
-
if (meta.properties[pk].kind !==
|
|
162
|
+
if (meta.properties[pk].kind !== ReferenceKind.SCALAR) {
|
|
165
163
|
lines.push(` (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference)) ? entity${this.wrap(pk)}.__helper.getSerializedPrimaryKey() : entity${this.wrap(pk)},`);
|
|
166
164
|
}
|
|
167
165
|
else {
|
|
@@ -169,22 +167,31 @@ class EntityComparator {
|
|
|
169
167
|
}
|
|
170
168
|
});
|
|
171
169
|
lines.push(` ];`);
|
|
172
|
-
lines.push(` return pks.join('${
|
|
170
|
+
lines.push(` return pks.join('${Utils.PK_SEPARATOR}');`);
|
|
173
171
|
}
|
|
174
172
|
else {
|
|
175
173
|
const pk = meta.primaryKeys[0];
|
|
176
|
-
|
|
174
|
+
const prop = meta.properties[pk];
|
|
175
|
+
if (prop.kind !== ReferenceKind.SCALAR) {
|
|
177
176
|
lines.push(` if (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference)) return entity${this.wrap(pk)}.__helper.getSerializedPrimaryKey();`);
|
|
178
177
|
}
|
|
179
178
|
const serializedPrimaryKey = meta.props.find(p => p.serializedPrimaryKey);
|
|
180
179
|
if (serializedPrimaryKey) {
|
|
181
180
|
lines.push(` return '' + entity.${serializedPrimaryKey.name};`);
|
|
182
181
|
}
|
|
183
|
-
|
|
182
|
+
else if (prop.customType) {
|
|
183
|
+
const convertorKey = this.registerCustomType(meta.properties[pk], context);
|
|
184
|
+
const idx = this.tmpIndex++;
|
|
185
|
+
lines.push(` const val_${idx} = convertToDatabaseValue_${convertorKey}(entity${this.wrap(pk)});`);
|
|
186
|
+
lines.push(` return getPrimaryKeyHash(val_${idx});`);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
lines.push(` return '' + entity${this.wrap(pk)};`);
|
|
190
|
+
}
|
|
184
191
|
}
|
|
185
192
|
const code = `// compiled pk serializer for entity ${meta.className}\n`
|
|
186
193
|
+ `return function(entity) {\n${lines.join('\n')}\n}`;
|
|
187
|
-
const pkSerializer =
|
|
194
|
+
const pkSerializer = Utils.createFunction(context, code);
|
|
188
195
|
this.pkSerializers.set(meta.className, pkSerializer);
|
|
189
196
|
return pkSerializer;
|
|
190
197
|
}
|
|
@@ -192,6 +199,7 @@ class EntityComparator {
|
|
|
192
199
|
* @internal Highly performance-sensitive method.
|
|
193
200
|
*/
|
|
194
201
|
getSnapshotGenerator(entityName) {
|
|
202
|
+
entityName = Utils.className(entityName);
|
|
195
203
|
const exists = this.snapshotGenerators.get(entityName);
|
|
196
204
|
if (exists) {
|
|
197
205
|
return exists;
|
|
@@ -199,7 +207,7 @@ class EntityComparator {
|
|
|
199
207
|
const meta = this.metadata.find(entityName);
|
|
200
208
|
const lines = [];
|
|
201
209
|
const context = new Map();
|
|
202
|
-
context.set('clone',
|
|
210
|
+
context.set('clone', clone);
|
|
203
211
|
context.set('cloneEmbeddable', (o) => this.platform.cloneEmbeddable(o)); // do not clone prototypes
|
|
204
212
|
if (meta.discriminatorValue) {
|
|
205
213
|
lines.push(` ret${this.wrap(meta.root.discriminatorColumn)} = '${meta.discriminatorValue}'`);
|
|
@@ -209,11 +217,11 @@ class EntityComparator {
|
|
|
209
217
|
meta.comparableProps
|
|
210
218
|
.filter(prop => {
|
|
211
219
|
const root = getRootProperty(prop);
|
|
212
|
-
return prop === root || root.kind !==
|
|
220
|
+
return prop === root || root.kind !== ReferenceKind.EMBEDDED;
|
|
213
221
|
})
|
|
214
222
|
.forEach(prop => lines.push(this.getPropertySnapshot(meta, prop, context, this.wrap(prop.name), this.wrap(prop.name), [prop.name])));
|
|
215
223
|
const code = `return function(entity) {\n const ret = {};\n${lines.join('\n')}\n return ret;\n}`;
|
|
216
|
-
const snapshotGenerator =
|
|
224
|
+
const snapshotGenerator = Utils.createFunction(context, code);
|
|
217
225
|
this.snapshotGenerators.set(entityName, snapshotGenerator);
|
|
218
226
|
return snapshotGenerator;
|
|
219
227
|
}
|
|
@@ -277,10 +285,14 @@ class EntityComparator {
|
|
|
277
285
|
lines.push(`${padding} if (${value} == null || ${value} instanceof Date) {`);
|
|
278
286
|
lines.push(`${padding} ${key} = ${value};`);
|
|
279
287
|
if (!tz || tz === 'local') {
|
|
288
|
+
lines.push(`${padding} } else if (typeof ${value} === 'bigint') {`);
|
|
289
|
+
lines.push(`${padding} ${key} = parseDate(Number(${value}));`);
|
|
280
290
|
lines.push(`${padding} } else {`);
|
|
281
291
|
lines.push(`${padding} ${key} = parseDate(${value});`);
|
|
282
292
|
}
|
|
283
293
|
else {
|
|
294
|
+
lines.push(`${padding} } else if (typeof ${value} === 'bigint') {`);
|
|
295
|
+
lines.push(`${padding} ${key} = parseDate(Number(${value}));`);
|
|
284
296
|
lines.push(`${padding} } else if (typeof ${value} === 'number' || ${value}.includes('+') || ${value}.lastIndexOf('-') > 10 || ${value}.endsWith('Z')) {`);
|
|
285
297
|
lines.push(`${padding} ${key} = parseDate(${value});`);
|
|
286
298
|
lines.push(`${padding} } else {`);
|
|
@@ -289,60 +301,76 @@ class EntityComparator {
|
|
|
289
301
|
lines.push(`${padding} }`);
|
|
290
302
|
};
|
|
291
303
|
lines.push(` const mapped = {};`);
|
|
292
|
-
meta
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
304
|
+
const mapEntityProperties = (meta, padding = '') => {
|
|
305
|
+
for (const prop of meta.props) {
|
|
306
|
+
if (!prop.fieldNames) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (prop.targetMeta && prop.fieldNames.length > 1) {
|
|
310
|
+
lines.push(`${padding} if (${prop.fieldNames.map(field => `typeof ${this.propName(field)} === 'undefined'`).join(' && ')}) {`);
|
|
311
|
+
lines.push(`${padding} } else if (${prop.fieldNames.map(field => `${this.propName(field)} != null`).join(' && ')}) {`);
|
|
312
|
+
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.createCompositeKeyArray(prop)};`);
|
|
313
|
+
lines.push(...prop.fieldNames.map(field => `${padding} ${this.propName(field, 'mapped')} = true;`));
|
|
314
|
+
lines.push(`${padding} } else if (${prop.fieldNames.map(field => `${this.propName(field)} == null`).join(' && ')}) {\n ret${this.wrap(prop.name)} = null;`);
|
|
315
|
+
lines.push(...prop.fieldNames.map(field => `${padding} ${this.propName(field, 'mapped')} = true;`), ' }');
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if (prop.embedded && (meta.embeddable || meta.properties[prop.embedded[0]].object)) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (prop.runtimeType === 'boolean') {
|
|
322
|
+
lines.push(`${padding} if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
|
|
323
|
+
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])} == null ? ${this.propName(prop.fieldNames[0])} : !!${this.propName(prop.fieldNames[0])};`);
|
|
324
|
+
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
325
|
+
lines.push(`${padding} }`);
|
|
326
|
+
}
|
|
327
|
+
else if (prop.runtimeType === 'Date' && !this.platform.isNumericProperty(prop)) {
|
|
328
|
+
lines.push(`${padding} if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
|
|
329
|
+
context.set('parseDate', (value) => this.platform.parseDate(value));
|
|
330
|
+
parseDate('ret' + this.wrap(prop.name), this.propName(prop.fieldNames[0]), padding);
|
|
331
|
+
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
332
|
+
lines.push(`${padding} }`);
|
|
333
|
+
}
|
|
334
|
+
else if (prop.kind === ReferenceKind.EMBEDDED && (prop.object || meta.embeddable)) {
|
|
335
|
+
const idx = this.tmpIndex++;
|
|
336
|
+
context.set(`mapEmbeddedResult_${idx}`, (data) => {
|
|
337
|
+
const item = parseJsonSafe(data);
|
|
338
|
+
if (Array.isArray(item)) {
|
|
339
|
+
return item.map(row => row == null ? row : this.getResultMapper(prop.type)(row));
|
|
340
|
+
}
|
|
341
|
+
return item == null ? item : this.getResultMapper(prop.type)(item);
|
|
342
|
+
});
|
|
343
|
+
lines.push(`${padding} if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
|
|
344
|
+
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])} == null ? ${this.propName(prop.fieldNames[0])} : mapEmbeddedResult_${idx}(${this.propName(prop.fieldNames[0])});`);
|
|
345
|
+
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
346
|
+
lines.push(`${padding} }`);
|
|
347
|
+
}
|
|
348
|
+
else if (prop.kind !== ReferenceKind.EMBEDDED) {
|
|
349
|
+
lines.push(`${padding} if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
|
|
350
|
+
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])};`);
|
|
351
|
+
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
352
|
+
lines.push(`${padding} }`);
|
|
353
|
+
}
|
|
334
354
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
355
|
+
};
|
|
356
|
+
if (meta.polymorphs && meta.discriminatorColumn) {
|
|
357
|
+
for (const polymorph of meta.polymorphs) {
|
|
358
|
+
const first = polymorph === meta.polymorphs[0];
|
|
359
|
+
lines.push(` ${first ? '' : 'else '}if (${this.propName(meta.discriminatorColumn)} == '${polymorph.discriminatorValue}') {`);
|
|
360
|
+
mapEntityProperties(polymorph, ' ');
|
|
339
361
|
lines.push(` }`);
|
|
340
362
|
}
|
|
341
|
-
|
|
342
|
-
|
|
363
|
+
lines.push(` else {`);
|
|
364
|
+
mapEntityProperties(meta, ' ');
|
|
365
|
+
lines.push(` }`);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
mapEntityProperties(meta);
|
|
369
|
+
}
|
|
370
|
+
lines.push(` for (let k in result) { if (Object.hasOwn(result, k) && !mapped[k] && ret[k] === undefined) ret[k] = result[k]; }`);
|
|
343
371
|
const code = `// compiled mapper for entity ${meta.className}\n`
|
|
344
372
|
+ `return function(result) {\n const ret = {};\n${lines.join('\n')}\n return ret;\n}`;
|
|
345
|
-
const resultMapper =
|
|
373
|
+
const resultMapper = Utils.createFunction(context, code);
|
|
346
374
|
this.mappers.set(entityName, resultMapper);
|
|
347
375
|
return resultMapper;
|
|
348
376
|
}
|
|
@@ -394,11 +422,21 @@ class EntityComparator {
|
|
|
394
422
|
}
|
|
395
423
|
getEmbeddedPropertySnapshot(meta, prop, context, level, path, dataKey, object = prop.object) {
|
|
396
424
|
const padding = ' '.repeat(level * 2);
|
|
425
|
+
const nullCond = `entity${path.map(k => this.wrap(k)).join('')} === null`;
|
|
397
426
|
let ret = `${level === 1 ? '' : '\n'}`;
|
|
398
427
|
if (object) {
|
|
399
|
-
const nullCond = `entity${path.map(k => this.wrap(k)).join('')} === null`;
|
|
400
428
|
ret += `${padding}if (${nullCond}) ret${dataKey} = null;\n`;
|
|
401
429
|
}
|
|
430
|
+
else {
|
|
431
|
+
ret += `${padding}if (${nullCond}) {\n`;
|
|
432
|
+
ret += meta.props.filter(p => p.embedded?.[0] === prop.name
|
|
433
|
+
// object for JSON embeddable
|
|
434
|
+
&& (p.object || (p.persist !== false))).map(childProp => {
|
|
435
|
+
const childDataKey = meta.embeddable || prop.object ? dataKey + this.wrap(childProp.embedded[1]) : this.wrap(childProp.name);
|
|
436
|
+
return `${padding} ret${childDataKey} = null;`;
|
|
437
|
+
}).join('\n') + `\n`;
|
|
438
|
+
ret += `${padding}}\n`;
|
|
439
|
+
}
|
|
402
440
|
const cond = `entity${path.map(k => this.wrap(k)).join('')} != null`;
|
|
403
441
|
ret += `${padding}if (${cond}) {\n`;
|
|
404
442
|
if (object) {
|
|
@@ -408,7 +446,7 @@ class EntityComparator {
|
|
|
408
446
|
if (!childProp.customType) {
|
|
409
447
|
return false;
|
|
410
448
|
}
|
|
411
|
-
if (childProp.customType instanceof
|
|
449
|
+
if (childProp.customType instanceof JsonType) {
|
|
412
450
|
return !prop.object;
|
|
413
451
|
}
|
|
414
452
|
return true;
|
|
@@ -419,10 +457,10 @@ class EntityComparator {
|
|
|
419
457
|
const childDataKey = meta.embeddable || prop.object ? dataKey + this.wrap(childProp.embedded[1]) : this.wrap(childProp.name);
|
|
420
458
|
const childEntityKey = [...path, childProp.embedded[1]].map(k => this.wrap(k)).join('');
|
|
421
459
|
const childCond = `typeof entity${childEntityKey} !== 'undefined'`;
|
|
422
|
-
if (childProp.kind ===
|
|
460
|
+
if (childProp.kind === ReferenceKind.EMBEDDED) {
|
|
423
461
|
return this.getPropertySnapshot(meta, childProp, context, childDataKey, childEntityKey, [...path, childProp.embedded[1]], level + 1, prop.object);
|
|
424
462
|
}
|
|
425
|
-
if (childProp.kind !==
|
|
463
|
+
if (childProp.kind !== ReferenceKind.SCALAR) {
|
|
426
464
|
return this.getPropertySnapshot(meta, childProp, context, childDataKey, childEntityKey, [...path, childProp.embedded[1]], level, prop.object)
|
|
427
465
|
.split('\n').map(l => padding + l).join('\n');
|
|
428
466
|
}
|
|
@@ -443,8 +481,8 @@ class EntityComparator {
|
|
|
443
481
|
registerCustomType(prop, context) {
|
|
444
482
|
const convertorKey = this.safeKey(prop.name);
|
|
445
483
|
context.set(`convertToDatabaseValue_${convertorKey}`, (val) => {
|
|
446
|
-
/*
|
|
447
|
-
if (
|
|
484
|
+
/* v8 ignore next */
|
|
485
|
+
if (RawQueryFragment.isKnownFragment(val)) {
|
|
448
486
|
return val;
|
|
449
487
|
}
|
|
450
488
|
return prop.customType.convertToDatabaseValue(val, this.platform, { mode: 'serialization' });
|
|
@@ -457,13 +495,13 @@ class EntityComparator {
|
|
|
457
495
|
if (['number', 'string', 'boolean'].includes(prop.type.toLowerCase())) {
|
|
458
496
|
return ret + ` ret${dataKey} = entity${entityKey}${unwrap};\n }\n`;
|
|
459
497
|
}
|
|
460
|
-
if (prop.kind ===
|
|
498
|
+
if (prop.kind === ReferenceKind.EMBEDDED) {
|
|
461
499
|
if (prop.array) {
|
|
462
500
|
return this.getEmbeddedArrayPropertySnapshot(meta, prop, context, level, path, dataKey) + '\n';
|
|
463
501
|
}
|
|
464
502
|
return this.getEmbeddedPropertySnapshot(meta, prop, context, level, path, dataKey, object) + '\n';
|
|
465
503
|
}
|
|
466
|
-
if (prop.kind ===
|
|
504
|
+
if (prop.kind === ReferenceKind.ONE_TO_ONE || prop.kind === ReferenceKind.MANY_TO_ONE) {
|
|
467
505
|
if (prop.mapToPk) {
|
|
468
506
|
if (prop.customType) {
|
|
469
507
|
const convertorKey = this.registerCustomType(prop, context);
|
|
@@ -475,7 +513,7 @@ class EntityComparator {
|
|
|
475
513
|
}
|
|
476
514
|
else {
|
|
477
515
|
const toArray = (val) => {
|
|
478
|
-
if (
|
|
516
|
+
if (Utils.isPlainObject(val)) {
|
|
479
517
|
return Object.values(val).map(v => toArray(v));
|
|
480
518
|
}
|
|
481
519
|
return val;
|
|
@@ -513,22 +551,32 @@ class EntityComparator {
|
|
|
513
551
|
const meta = this.metadata.find(entityName);
|
|
514
552
|
const lines = [];
|
|
515
553
|
const context = new Map();
|
|
516
|
-
context.set('compareArrays',
|
|
517
|
-
context.set('compareBooleans',
|
|
518
|
-
context.set('compareBuffers',
|
|
519
|
-
context.set('compareObjects',
|
|
520
|
-
context.set('equals',
|
|
521
|
-
meta.comparableProps
|
|
554
|
+
context.set('compareArrays', compareArrays);
|
|
555
|
+
context.set('compareBooleans', compareBooleans);
|
|
556
|
+
context.set('compareBuffers', compareBuffers);
|
|
557
|
+
context.set('compareObjects', compareObjects);
|
|
558
|
+
context.set('equals', equals);
|
|
559
|
+
for (const prop of meta.comparableProps) {
|
|
522
560
|
lines.push(this.getPropertyComparator(prop, context));
|
|
523
|
-
}
|
|
561
|
+
}
|
|
562
|
+
// also compare 1:1 inverse sides, important for `factory.mergeData`
|
|
563
|
+
lines.push(`if (options?.includeInverseSides) {`);
|
|
564
|
+
for (const prop of meta.bidirectionalRelations) {
|
|
565
|
+
if (prop.kind === ReferenceKind.ONE_TO_ONE && !prop.owner && prop.hydrate !== false) {
|
|
566
|
+
lines.push(this.getPropertyComparator(prop, context));
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
lines.push(`}`);
|
|
524
570
|
const code = `// compiled comparator for entity ${meta.className}\n`
|
|
525
|
-
+ `return function(last, current) {\n const diff = {};\n${lines.join('\n')}\n return diff;\n}`;
|
|
526
|
-
const comparator =
|
|
571
|
+
+ `return function(last, current, options) {\n const diff = {};\n${lines.join('\n')}\n return diff;\n}`;
|
|
572
|
+
const comparator = Utils.createFunction(context, code);
|
|
527
573
|
this.comparators.set(entityName, comparator);
|
|
528
574
|
return comparator;
|
|
529
575
|
}
|
|
530
576
|
getGenericComparator(prop, cond) {
|
|
531
|
-
return ` if (current${prop}
|
|
577
|
+
return ` if (current${prop} === null && last${prop} === undefined) {\n` +
|
|
578
|
+
` diff${prop} = current${prop};\n` +
|
|
579
|
+
` } else if (current${prop} == null && last${prop} == null) {\n\n` +
|
|
532
580
|
` } else if ((current${prop} != null && last${prop} == null) || (current${prop} == null && last${prop} != null)) {\n` +
|
|
533
581
|
` diff${prop} = current${prop};\n` +
|
|
534
582
|
` } else if (${cond}) {\n` +
|
|
@@ -537,7 +585,7 @@ class EntityComparator {
|
|
|
537
585
|
}
|
|
538
586
|
getPropertyComparator(prop, context) {
|
|
539
587
|
let type = prop.type.toLowerCase();
|
|
540
|
-
if (prop.kind !==
|
|
588
|
+
if (prop.kind !== ReferenceKind.SCALAR && prop.kind !== ReferenceKind.EMBEDDED) {
|
|
541
589
|
const meta2 = this.metadata.find(prop.type);
|
|
542
590
|
if (meta2.primaryKeys.length > 1) {
|
|
543
591
|
type = 'array';
|
|
@@ -569,10 +617,10 @@ class EntityComparator {
|
|
|
569
617
|
if (['buffer', 'uint8array'].includes(type)) {
|
|
570
618
|
return this.getGenericComparator(this.wrap(prop.name), `!compareBuffers(last${this.wrap(prop.name)}, current${this.wrap(prop.name)})`);
|
|
571
619
|
}
|
|
572
|
-
if (
|
|
620
|
+
if (type === 'date') {
|
|
573
621
|
return this.getGenericComparator(this.wrap(prop.name), `last${this.wrap(prop.name)}.valueOf() !== current${this.wrap(prop.name)}.valueOf()`);
|
|
574
622
|
}
|
|
575
|
-
if (
|
|
623
|
+
if (type === 'objectid') {
|
|
576
624
|
// We might be comparing PK to object, in case we compare with cached data of populated entity
|
|
577
625
|
// in such case we just ignore the comparison and fallback to `equals()` (which will still mark
|
|
578
626
|
// it as not equal as we compare PK to plain object).
|
|
@@ -594,11 +642,10 @@ class EntityComparator {
|
|
|
594
642
|
* perf: used to generate list of comparable properties during discovery, so we speed up the runtime comparison
|
|
595
643
|
*/
|
|
596
644
|
static isComparable(prop, root) {
|
|
597
|
-
const virtual = prop.persist === false || prop.generated;
|
|
598
|
-
const inverse = prop.kind ===
|
|
645
|
+
const virtual = prop.persist === false || (prop.generated && !prop.primary);
|
|
646
|
+
const inverse = prop.kind === ReferenceKind.ONE_TO_ONE && !prop.owner;
|
|
599
647
|
const discriminator = prop.name === root.discriminatorColumn;
|
|
600
|
-
const collection = prop.kind ===
|
|
648
|
+
const collection = prop.kind === ReferenceKind.ONE_TO_MANY || prop.kind === ReferenceKind.MANY_TO_MANY;
|
|
601
649
|
return !virtual && !collection && !inverse && !discriminator && !prop.version;
|
|
602
650
|
}
|
|
603
651
|
}
|
|
604
|
-
exports.EntityComparator = EntityComparator;
|
package/utils/NullHighlighter.js
CHANGED
package/utils/QueryHelper.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import type { Dictionary, EntityMetadata, EntityProperty, FilterDef, FilterQuery } from '../typings';
|
|
2
|
-
import type { Platform } from '../platforms';
|
|
3
|
-
import type { MetadataStorage } from '../metadata/MetadataStorage';
|
|
1
|
+
import type { Dictionary, EntityMetadata, EntityProperty, FilterDef, FilterQuery } from '../typings.js';
|
|
2
|
+
import type { Platform } from '../platforms/Platform.js';
|
|
3
|
+
import type { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
4
|
+
import type { FilterOptions } from '../drivers/IDatabaseDriver.js';
|
|
5
|
+
/** @internal */
|
|
4
6
|
export declare class QueryHelper {
|
|
5
7
|
static readonly SUPPORTED_OPERATORS: string[];
|
|
6
8
|
static processParams(params: unknown): any;
|
|
7
9
|
static processObjectParams<T extends object>(params?: T): T;
|
|
10
|
+
/**
|
|
11
|
+
* converts `{ account: { $or: [ [Object], [Object] ] } }`
|
|
12
|
+
* to `{ $or: [ { account: [Object] }, { account: [Object] } ] }`
|
|
13
|
+
*/
|
|
14
|
+
static liftGroupOperators<T extends object>(where: Dictionary, meta: EntityMetadata<T>, metadata: MetadataStorage, key?: string): string | undefined;
|
|
8
15
|
static inlinePrimaryKeyObjects<T extends object>(where: Dictionary, meta: EntityMetadata<T>, metadata: MetadataStorage, key?: string): boolean;
|
|
9
16
|
static processWhere<T extends object>(options: ProcessWhereOptions<T>): FilterQuery<T>;
|
|
10
|
-
static getActiveFilters(entityName: string, options:
|
|
17
|
+
static getActiveFilters(entityName: string, options: FilterOptions | undefined, filters: Dictionary<FilterDef>): FilterDef[];
|
|
18
|
+
static mergePropertyFilters(propFilters: FilterOptions | undefined, options: FilterOptions | undefined): FilterOptions | undefined;
|
|
11
19
|
static isFilterActive(entityName: string, filterName: string, filter: FilterDef, options: Dictionary<boolean | Dictionary>): boolean;
|
|
12
20
|
static processCustomType<T extends object>(prop: EntityProperty<T>, cond: FilterQuery<T>, platform: Platform, key?: string, fromQuery?: boolean): FilterQuery<T>;
|
|
13
21
|
private static isSupportedOperator;
|