@mikro-orm/core 6.4.12-dev.16 → 6.4.12-dev.18
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.
|
@@ -1124,7 +1124,7 @@ class MetadataDiscovery {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
const mappedType = this.getMappedType(prop);
|
|
1126
1126
|
if (prop.fieldNames?.length === 1 && !prop.customType) {
|
|
1127
|
-
[types_1.BigIntType, types_1.DoubleType, types_1.DecimalType, types_1.IntervalType]
|
|
1127
|
+
[types_1.BigIntType, types_1.DoubleType, types_1.DecimalType, types_1.IntervalType, types_1.DateType]
|
|
1128
1128
|
.filter(type => mappedType instanceof type)
|
|
1129
1129
|
.forEach(type => prop.customType = new type());
|
|
1130
1130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.4.12-dev.
|
|
3
|
+
"version": "6.4.12-dev.18",
|
|
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.12-dev.
|
|
67
|
+
"mikro-orm": "6.4.12-dev.18",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/typings.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
|
|
|
168
168
|
__touched: boolean;
|
|
169
169
|
__originalEntityData?: EntityData<Entity>;
|
|
170
170
|
__loadedProperties: Set<string>;
|
|
171
|
-
__identifier?: EntityIdentifier;
|
|
171
|
+
__identifier?: EntityIdentifier | EntityIdentifier[];
|
|
172
172
|
__managed: boolean;
|
|
173
173
|
__processing: boolean;
|
|
174
174
|
__schema?: string;
|
|
@@ -211,7 +211,9 @@ class ChangeSetPersister {
|
|
|
211
211
|
// of using the raw value from db, we convert it back to the db value explicitly
|
|
212
212
|
value = prop.customType ? prop.customType.convertToDatabaseValue(insertId, this.platform, { mode: 'serialization' }) : value;
|
|
213
213
|
changeSet.payload[wrapped.__meta.primaryKeys[0]] = value;
|
|
214
|
-
wrapped.__identifier
|
|
214
|
+
if (wrapped.__identifier && !Array.isArray(wrapped.__identifier)) {
|
|
215
|
+
wrapped.__identifier.setValue(value);
|
|
216
|
+
}
|
|
215
217
|
}
|
|
216
218
|
/**
|
|
217
219
|
* Sets populate flag to new entities so they are serialized like if they were loaded from the db
|
|
@@ -339,6 +341,10 @@ class ChangeSetPersister {
|
|
|
339
341
|
changeSet.payload[prop.name] = value.getValue();
|
|
340
342
|
return;
|
|
341
343
|
}
|
|
344
|
+
if (Array.isArray(value) && value.every(item => item instanceof entity_1.EntityIdentifier)) {
|
|
345
|
+
changeSet.payload[prop.name] = value.map(item => item.getValue());
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
342
348
|
if (prop.kind === enums_1.ReferenceKind.MANY_TO_MANY && Array.isArray(value)) {
|
|
343
349
|
changeSet.payload[prop.name] = value.map(val => val instanceof entity_1.EntityIdentifier ? val.getValue() : val);
|
|
344
350
|
return;
|
|
@@ -542,13 +542,22 @@ class UnitOfWork {
|
|
|
542
542
|
if (!wrapped || wrapped.__identifier || wrapped.hasPrimaryKey()) {
|
|
543
543
|
return;
|
|
544
544
|
}
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
545
|
+
const pks = wrapped.__meta.getPrimaryProps();
|
|
546
|
+
const idents = [];
|
|
547
|
+
for (const pk of pks) {
|
|
548
|
+
if (pk.kind === enums_1.ReferenceKind.SCALAR) {
|
|
549
|
+
idents.push(new entity_1.EntityIdentifier(entity[pk.name]));
|
|
550
|
+
}
|
|
551
|
+
else if (entity[pk.name]) {
|
|
552
|
+
this.initIdentifier(entity[pk.name]);
|
|
553
|
+
idents.push((0, entity_1.helper)(entity[pk.name])?.__identifier);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (pks.length === 1) {
|
|
557
|
+
wrapped.__identifier = idents[0];
|
|
548
558
|
}
|
|
549
|
-
else
|
|
550
|
-
|
|
551
|
-
wrapped.__identifier = (0, entity_1.helper)(entity[pk.name])?.__identifier;
|
|
559
|
+
else {
|
|
560
|
+
wrapped.__identifier = idents;
|
|
552
561
|
}
|
|
553
562
|
}
|
|
554
563
|
processReference(parent, prop, kind, visited, processed, idx) {
|
|
@@ -600,8 +609,15 @@ class UnitOfWork {
|
|
|
600
609
|
const diff = this.comparator.diffEntities(changeSet.name, copy, current);
|
|
601
610
|
Object.assign(changeSet.payload, diff);
|
|
602
611
|
const wrapped = (0, entity_1.helper)(changeSet.entity);
|
|
603
|
-
if (wrapped.__identifier
|
|
604
|
-
|
|
612
|
+
if (wrapped.__identifier) {
|
|
613
|
+
const idents = Utils_1.Utils.asArray(wrapped.__identifier);
|
|
614
|
+
let i = 0;
|
|
615
|
+
for (const pk of wrapped.__meta.primaryKeys) {
|
|
616
|
+
if (diff[pk]) {
|
|
617
|
+
idents[i].setValue(diff[pk]);
|
|
618
|
+
}
|
|
619
|
+
i++;
|
|
620
|
+
}
|
|
605
621
|
}
|
|
606
622
|
}
|
|
607
623
|
postCommitCleanup() {
|