@mikro-orm/core 6.4.1-dev.18 → 6.4.1-dev.19
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/package.json +2 -2
- package/typings.d.ts +1 -0
- package/typings.js +3 -0
- package/unit-of-work/ChangeSet.js +8 -0
- package/utils/EntityComparator.js +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.4.1-dev.
|
|
3
|
+
"version": "6.4.1-dev.19",
|
|
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.2.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.4.1-dev.
|
|
67
|
+
"mikro-orm": "6.4.1-dev.19",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/typings.d.ts
CHANGED
|
@@ -388,6 +388,7 @@ export declare class EntityMetadata<T = any> {
|
|
|
388
388
|
addProperty(prop: Partial<EntityProperty<T>>, sync?: boolean): void;
|
|
389
389
|
removeProperty(name: string, sync?: boolean): void;
|
|
390
390
|
getPrimaryProps(): EntityProperty<T>[];
|
|
391
|
+
getPrimaryProp(): EntityProperty<T>;
|
|
391
392
|
get tableName(): string;
|
|
392
393
|
set tableName(name: string);
|
|
393
394
|
sync(initIndexes?: boolean): void;
|
package/typings.js
CHANGED
|
@@ -31,6 +31,14 @@ class ChangeSet {
|
|
|
31
31
|
else {
|
|
32
32
|
this.primaryKey = this.originalEntity[this.meta.primaryKeys[0]];
|
|
33
33
|
}
|
|
34
|
+
if (!this.meta.compositePK
|
|
35
|
+
&& this.meta.getPrimaryProp().targetMeta?.compositePK
|
|
36
|
+
&& typeof this.primaryKey === 'object'
|
|
37
|
+
&& this.primaryKey !== null) {
|
|
38
|
+
this.primaryKey = this.meta.getPrimaryProp().targetMeta.primaryKeys.map(childPK => {
|
|
39
|
+
return this.primaryKey[childPK];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
34
42
|
if (object && this.primaryKey != null) {
|
|
35
43
|
return Utils_1.Utils.primaryKeyToObject(this.meta, this.primaryKey);
|
|
36
44
|
}
|
|
@@ -74,7 +74,19 @@ class EntityComparator {
|
|
|
74
74
|
else {
|
|
75
75
|
const pk = meta.primaryKeys[0];
|
|
76
76
|
if (meta.properties[pk].kind !== enums_1.ReferenceKind.SCALAR) {
|
|
77
|
-
lines.push(` if (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference))
|
|
77
|
+
lines.push(` if (entity${this.wrap(pk)} != null && (entity${this.wrap(pk)}.__entity || entity${this.wrap(pk)}.__reference)) {`);
|
|
78
|
+
lines.push(` const pk = entity${this.wrap(pk)}.__helper.getPrimaryKey();`);
|
|
79
|
+
if (meta.properties[pk].targetMeta.compositePK) {
|
|
80
|
+
lines.push(` if (typeof pk === 'object') {`);
|
|
81
|
+
lines.push(` return [`);
|
|
82
|
+
for (const childPK of meta.properties[pk].targetMeta.primaryKeys) {
|
|
83
|
+
lines.push(` pk${this.wrap(childPK)},`);
|
|
84
|
+
}
|
|
85
|
+
lines.push(` ];`);
|
|
86
|
+
lines.push(` }`);
|
|
87
|
+
}
|
|
88
|
+
lines.push(` return pk;`);
|
|
89
|
+
lines.push(` }`);
|
|
78
90
|
}
|
|
79
91
|
lines.push(` return entity${this.wrap(pk)};`);
|
|
80
92
|
}
|