@mikro-orm/core 7.2.2-dev.26 → 7.2.2-dev.28
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.
|
@@ -407,7 +407,7 @@ export class ObjectHydrator extends Hydrator {
|
|
|
407
407
|
const code = `// compiled hydrator for entity ${meta.className} (${type + normalizeAccessors ? ' normalized' : ''})\n` +
|
|
408
408
|
`return function(entity, data, factory, newEntity, convertCustomTypes, schema, parentSchema, normalizeAccessors) {\n` +
|
|
409
409
|
`${lines.join('\n')}\n}`;
|
|
410
|
-
const fnKey = `hydrator-${meta.
|
|
410
|
+
const fnKey = `hydrator-${meta.compiledName}-${type}-${normalizeAccessors}`;
|
|
411
411
|
const hydrator = Utils.createFunction(context, code, this.config.get('compiledFunctions'), fnKey);
|
|
412
412
|
this.#hydrators[key].set(meta.class, hydrator);
|
|
413
413
|
return hydrator;
|
|
@@ -110,6 +110,12 @@ export class MetadataStorage {
|
|
|
110
110
|
if (existing && existing !== meta && existing.class !== meta.class) {
|
|
111
111
|
this.#ambiguousNames.add(className);
|
|
112
112
|
}
|
|
113
|
+
// colliding names are numbered in storage order, which follows the discovery config, not module evaluation
|
|
114
|
+
const sameName = this.#ambiguousNames.has(className)
|
|
115
|
+
? [...new Set(this.#metadataMap.values())].filter(m => m.className === meta.className)
|
|
116
|
+
: [meta];
|
|
117
|
+
const ordinal = sameName.indexOf(meta);
|
|
118
|
+
meta.compiledName = ordinal > 0 ? `${meta.className}#${ordinal}` : meta.className;
|
|
113
119
|
this.#classNameMap[className] = meta;
|
|
114
120
|
return meta;
|
|
115
121
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.2-dev.
|
|
3
|
+
"version": "7.2.2-dev.28",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
package/typings.d.ts
CHANGED
|
@@ -1255,6 +1255,8 @@ export interface EntityMetadata<Entity = any, Class extends EntityCtor<Entity> =
|
|
|
1255
1255
|
orderBy?: QueryOrderMap<Entity> | QueryOrderMap<Entity>[];
|
|
1256
1256
|
/** @internal can be used for computed numeric cache keys */
|
|
1257
1257
|
readonly _id: number;
|
|
1258
|
+
/** @internal name that does not depend on module evaluation order (unlike `_id`), used to key `compiledFunctions` */
|
|
1259
|
+
compiledName?: string;
|
|
1258
1260
|
}
|
|
1259
1261
|
/** Options for `ISchemaGenerator.create()`. */
|
|
1260
1262
|
export interface CreateSchemaOptions {
|
|
@@ -95,7 +95,7 @@ export class EntityComparator {
|
|
|
95
95
|
lines.push(` return entity${this.wrap(pk)};`);
|
|
96
96
|
}
|
|
97
97
|
const code = `// compiled pk getter for entity ${meta.className}\n` + `return function(entity) {\n${lines.join('\n')}\n}`;
|
|
98
|
-
const fnKey = `pkGetter-${meta.
|
|
98
|
+
const fnKey = `pkGetter-${meta.compiledName}`;
|
|
99
99
|
const pkSerializer = Utils.createFunction(context, code, this.#config?.get('compiledFunctions'), fnKey);
|
|
100
100
|
this.#pkGetters.set(meta, pkSerializer);
|
|
101
101
|
return pkSerializer;
|
|
@@ -147,7 +147,7 @@ export class EntityComparator {
|
|
|
147
147
|
}
|
|
148
148
|
const code = `// compiled pk getter (with converted custom types) for entity ${meta.className}\n` +
|
|
149
149
|
`return function(entity) {\n${lines.join('\n')}\n}`;
|
|
150
|
-
const fnKey = `pkGetterConverted-${meta.
|
|
150
|
+
const fnKey = `pkGetterConverted-${meta.compiledName}`;
|
|
151
151
|
const pkSerializer = Utils.createFunction(context, code, this.#config?.get('compiledFunctions'), fnKey);
|
|
152
152
|
this.#pkGettersConverted.set(meta, pkSerializer);
|
|
153
153
|
return pkSerializer;
|
|
@@ -206,7 +206,7 @@ export class EntityComparator {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
const code = `// compiled pk serializer for entity ${meta.className}\n` + `return function(entity) {\n${lines.join('\n')}\n}`;
|
|
209
|
-
const fnKey = `pkSerializer-${meta.
|
|
209
|
+
const fnKey = `pkSerializer-${meta.compiledName}`;
|
|
210
210
|
const pkSerializer = Utils.createFunction(context, code, this.#config?.get('compiledFunctions'), fnKey);
|
|
211
211
|
this.#pkSerializers.set(meta, pkSerializer);
|
|
212
212
|
return pkSerializer;
|
|
@@ -236,7 +236,7 @@ export class EntityComparator {
|
|
|
236
236
|
})
|
|
237
237
|
.forEach(prop => lines.push(this.getPropertySnapshot(meta, prop, context, this.wrap(prop.name), this.wrap(prop.name), [prop.name])));
|
|
238
238
|
const code = `return function(entity) {\n const ret = {};\n${lines.join('\n')}\n return ret;\n}`;
|
|
239
|
-
const fnKey = `snapshotGenerator-${meta.
|
|
239
|
+
const fnKey = `snapshotGenerator-${meta.compiledName}`;
|
|
240
240
|
const snapshotGenerator = Utils.createFunction(context, code, this.#config?.get('compiledFunctions'), fnKey);
|
|
241
241
|
this.#snapshotGenerators.set(meta, snapshotGenerator);
|
|
242
242
|
return snapshotGenerator;
|
|
@@ -420,7 +420,7 @@ export class EntityComparator {
|
|
|
420
420
|
lines.push(` for (let k in result) { if (Object.hasOwn(result, k) && !mapped[k] && ret[k] === undefined${knownKeysGuard}) ret[k] = result[k]; }`);
|
|
421
421
|
const code = `// compiled mapper for entity ${meta.className}\n` +
|
|
422
422
|
`return function(result) {\n const ret = {};\n${lines.join('\n')}\n return ret;\n}`;
|
|
423
|
-
const fnKey = `resultMapper-${meta.
|
|
423
|
+
const fnKey = `resultMapper-${meta.compiledName}`;
|
|
424
424
|
const resultMapper = Utils.createFunction(context, code, this.#config?.get('compiledFunctions'), fnKey);
|
|
425
425
|
this.#mappers.set(meta, resultMapper);
|
|
426
426
|
return resultMapper;
|
|
@@ -703,7 +703,7 @@ export class EntityComparator {
|
|
|
703
703
|
lines.push(`}`);
|
|
704
704
|
const code = `// compiled comparator for entity ${meta.className}\n` +
|
|
705
705
|
`return function(last, current, options) {\n const diff = {};\n${lines.join('\n')}\n return diff;\n}`;
|
|
706
|
-
const fnKey = `comparator-${meta.
|
|
706
|
+
const fnKey = `comparator-${meta.compiledName}`;
|
|
707
707
|
const comparator = Utils.createFunction(context, code, this.#config?.get('compiledFunctions'), fnKey);
|
|
708
708
|
this.#comparators.set(meta, comparator);
|
|
709
709
|
return comparator;
|
package/utils/Utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
153
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
154
154
|
export class Utils {
|
|
155
155
|
static PK_SEPARATOR = '~~~';
|
|
156
|
-
static #ORM_VERSION = '7.2.2-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.2-dev.28';
|
|
157
157
|
/** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
|
|
158
158
|
static getRlsSettingName(filterName, argName) {
|
|
159
159
|
return `mikro.${filterName}.${argName}`;
|