@mikro-orm/core 6.4.14-dev.2 → 6.4.14-dev.20
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.js +27 -28
- package/decorators/ManyToOne.d.ts +2 -0
- package/decorators/OneToOne.d.ts +2 -0
- package/enums.d.ts +1 -1
- package/metadata/MetadataDiscovery.js +5 -1
- package/package.json +2 -2
- package/typings.d.ts +1 -0
- package/utils/EntityComparator.js +1 -1
package/EntityManager.js
CHANGED
|
@@ -710,6 +710,7 @@ class EntityManager {
|
|
|
710
710
|
ctx: em.transactionContext,
|
|
711
711
|
convertCustomTypes: true,
|
|
712
712
|
connectionType: 'write',
|
|
713
|
+
schema: options.schema,
|
|
713
714
|
});
|
|
714
715
|
em.getHydrator().hydrate(entity, meta, data2, em.entityFactory, 'full', false, true);
|
|
715
716
|
}
|
|
@@ -891,6 +892,7 @@ class EntityManager {
|
|
|
891
892
|
ctx: em.transactionContext,
|
|
892
893
|
convertCustomTypes: true,
|
|
893
894
|
connectionType: 'write',
|
|
895
|
+
schema: options.schema,
|
|
894
896
|
});
|
|
895
897
|
for (const [entity, cond] of loadPK.entries()) {
|
|
896
898
|
const row = data2.find(row => {
|
|
@@ -1261,7 +1263,7 @@ class EntityManager {
|
|
|
1261
1263
|
delete options.orderBy;
|
|
1262
1264
|
const cacheKey = em.cacheKey(entityName, options, 'em.count', where);
|
|
1263
1265
|
const cached = await em.tryCache(entityName, options.cache, cacheKey);
|
|
1264
|
-
if (cached?.data) {
|
|
1266
|
+
if (cached?.data !== undefined) {
|
|
1265
1267
|
return cached.data;
|
|
1266
1268
|
}
|
|
1267
1269
|
const count = await em.driver.count(entityName, where, { ctx: em.transactionContext, ...options });
|
|
@@ -1685,34 +1687,31 @@ class EntityManager {
|
|
|
1685
1687
|
const em = this.getContext();
|
|
1686
1688
|
const cacheKey = Array.isArray(config) ? config[0] : JSON.stringify(key);
|
|
1687
1689
|
const cached = await em.resultCache.get(cacheKey);
|
|
1688
|
-
if (cached
|
|
1689
|
-
return { key: cacheKey, data:
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
});
|
|
1708
|
-
}
|
|
1709
|
-
else {
|
|
1710
|
-
data = cached;
|
|
1711
|
-
}
|
|
1712
|
-
await em.unitOfWork.dispatchOnLoadEvent();
|
|
1713
|
-
return { key: cacheKey, data };
|
|
1690
|
+
if (!cached) {
|
|
1691
|
+
return { key: cacheKey, data: cached };
|
|
1692
|
+
}
|
|
1693
|
+
let data;
|
|
1694
|
+
if (Array.isArray(cached) && merge) {
|
|
1695
|
+
data = cached.map(item => em.entityFactory.create(entityName, item, {
|
|
1696
|
+
merge: true,
|
|
1697
|
+
convertCustomTypes: true,
|
|
1698
|
+
refresh,
|
|
1699
|
+
recomputeSnapshot: true,
|
|
1700
|
+
}));
|
|
1701
|
+
}
|
|
1702
|
+
else if (utils_1.Utils.isObject(cached) && merge) {
|
|
1703
|
+
data = em.entityFactory.create(entityName, cached, {
|
|
1704
|
+
merge: true,
|
|
1705
|
+
convertCustomTypes: true,
|
|
1706
|
+
refresh,
|
|
1707
|
+
recomputeSnapshot: true,
|
|
1708
|
+
});
|
|
1714
1709
|
}
|
|
1715
|
-
|
|
1710
|
+
else {
|
|
1711
|
+
data = cached;
|
|
1712
|
+
}
|
|
1713
|
+
await em.unitOfWork.dispatchOnLoadEvent();
|
|
1714
|
+
return { key: cacheKey, data };
|
|
1716
1715
|
}
|
|
1717
1716
|
/**
|
|
1718
1717
|
* @internal
|
|
@@ -27,4 +27,6 @@ export interface ManyToOneOptions<Owner, Target> extends ReferenceOptions<Owner,
|
|
|
27
27
|
updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
28
28
|
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
29
29
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
30
|
+
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
31
|
+
foreignKeyName?: string;
|
|
30
32
|
}
|
package/decorators/OneToOne.d.ts
CHANGED
|
@@ -21,4 +21,6 @@ export interface OneToOneOptions<Owner, Target> extends Partial<Omit<OneToManyOp
|
|
|
21
21
|
updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
22
22
|
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
23
23
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
24
|
+
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
25
|
+
foreignKeyName?: string;
|
|
24
26
|
}
|
package/enums.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare enum QueryOrderNumeric {
|
|
|
66
66
|
ASC = 1,
|
|
67
67
|
DESC = -1
|
|
68
68
|
}
|
|
69
|
-
export type QueryOrderKeysFlat = QueryOrder | QueryOrderNumeric |
|
|
69
|
+
export type QueryOrderKeysFlat = QueryOrder | QueryOrderNumeric | `${QueryOrder}`;
|
|
70
70
|
export type QueryOrderKeys<T> = QueryOrderKeysFlat | QueryOrderMap<T>;
|
|
71
71
|
export type QueryOrderMap<T> = {
|
|
72
72
|
[K in EntityKey<T>]?: QueryOrderKeys<ExpandProperty<T[K]>>;
|
|
@@ -264,7 +264,8 @@ class MetadataDiscovery {
|
|
|
264
264
|
// initialize global metadata for given entity
|
|
265
265
|
MetadataStorage_1.MetadataStorage.getMetadata(entity.meta.className, filepath);
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
const meta = Utils_1.Utils.copy(entity.meta, false);
|
|
268
|
+
return EntitySchema_1.EntitySchema.fromMetadata(meta);
|
|
268
269
|
}
|
|
269
270
|
const path = entity[MetadataStorage_1.MetadataStorage.PATH_SYMBOL];
|
|
270
271
|
if (path) {
|
|
@@ -1137,6 +1138,9 @@ class MetadataDiscovery {
|
|
|
1137
1138
|
prop.runtimeType ??= prop.customType.runtimeType;
|
|
1138
1139
|
}
|
|
1139
1140
|
}
|
|
1141
|
+
else if (prop.runtimeType === 'object') {
|
|
1142
|
+
prop.runtimeType = mappedType.runtimeType;
|
|
1143
|
+
}
|
|
1140
1144
|
else {
|
|
1141
1145
|
prop.runtimeType ??= mappedType.runtimeType;
|
|
1142
1146
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.4.14-dev.
|
|
3
|
+
"version": "6.4.14-dev.20",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.4.14-dev.
|
|
67
|
+
"mikro-orm": "6.4.14-dev.20",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/typings.d.ts
CHANGED
|
@@ -381,6 +381,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
381
381
|
optional?: boolean;
|
|
382
382
|
ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
|
|
383
383
|
deferMode?: DeferMode;
|
|
384
|
+
foreignKeyName?: string;
|
|
384
385
|
}
|
|
385
386
|
export declare class EntityMetadata<T = any> {
|
|
386
387
|
private static counter;
|
|
@@ -610,7 +610,7 @@ class EntityComparator {
|
|
|
610
610
|
* perf: used to generate list of comparable properties during discovery, so we speed up the runtime comparison
|
|
611
611
|
*/
|
|
612
612
|
static isComparable(prop, root) {
|
|
613
|
-
const virtual = prop.persist === false || prop.generated;
|
|
613
|
+
const virtual = prop.persist === false || (prop.generated && !prop.primary);
|
|
614
614
|
const inverse = prop.kind === enums_1.ReferenceKind.ONE_TO_ONE && !prop.owner;
|
|
615
615
|
const discriminator = prop.name === root.discriminatorColumn;
|
|
616
616
|
const collection = prop.kind === enums_1.ReferenceKind.ONE_TO_MANY || prop.kind === enums_1.ReferenceKind.MANY_TO_MANY;
|