@mikro-orm/core 6.2.10-dev.62 → 6.2.10-dev.63
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
CHANGED
|
@@ -603,7 +603,7 @@ class EntityManager {
|
|
|
603
603
|
em.prepareOptions(options);
|
|
604
604
|
let entityName;
|
|
605
605
|
let where;
|
|
606
|
-
let entity;
|
|
606
|
+
let entity = null;
|
|
607
607
|
if (data === undefined) {
|
|
608
608
|
entityName = entityNameOrEntity.constructor.name;
|
|
609
609
|
data = entityNameOrEntity;
|
|
@@ -661,13 +661,13 @@ class EntityManager {
|
|
|
661
661
|
convertCustomTypes,
|
|
662
662
|
...options,
|
|
663
663
|
});
|
|
664
|
+
em.unitOfWork.getChangeSetPersister().mapReturnedValues(entity, data, ret.row, meta, true);
|
|
664
665
|
entity ??= em.entityFactory.create(entityName, data, {
|
|
665
666
|
refresh: true,
|
|
666
667
|
initialized: true,
|
|
667
668
|
schema: options.schema,
|
|
668
669
|
convertCustomTypes: true,
|
|
669
670
|
});
|
|
670
|
-
em.unitOfWork.getChangeSetPersister().mapReturnedValues(entity, data, ret.row, meta, true);
|
|
671
671
|
const uniqueFields = options.onConflictFields ?? (utils_1.Utils.isPlainObject(where) ? Object.keys(where) : meta.primaryKeys);
|
|
672
672
|
const returning = (0, utils_1.getOnConflictReturningFields)(meta, data, uniqueFields, options);
|
|
673
673
|
if (options.onConflictAction === 'ignore' || !(0, entity_1.helper)(entity).hasPrimaryKey() || (returning.length > 0 && !(this.getPlatform().usesReturningStatement() && ret.row))) {
|
|
@@ -825,13 +825,13 @@ class EntityManager {
|
|
|
825
825
|
entitiesByData.clear();
|
|
826
826
|
const loadPK = new Map();
|
|
827
827
|
allData.forEach((row, i) => {
|
|
828
|
+
em.unitOfWork.getChangeSetPersister().mapReturnedValues(utils_1.Utils.isEntity(data[i]) ? data[i] : null, utils_1.Utils.isEntity(data[i]) ? {} : data[i], res.rows?.[i], meta, true);
|
|
828
829
|
const entity = utils_1.Utils.isEntity(data[i]) ? data[i] : em.entityFactory.create(entityName, row, {
|
|
829
830
|
refresh: true,
|
|
830
831
|
initialized: true,
|
|
831
832
|
schema: options.schema,
|
|
832
833
|
convertCustomTypes: true,
|
|
833
834
|
});
|
|
834
|
-
em.unitOfWork.getChangeSetPersister().mapReturnedValues(entity, utils_1.Utils.isEntity(data[i]) ? {} : data[i], res.rows?.[i], meta, true);
|
|
835
835
|
if (!(0, entity_1.helper)(entity).hasPrimaryKey()) {
|
|
836
836
|
loadPK.set(entity, allWhere[i]);
|
|
837
837
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.2.10-dev.
|
|
3
|
+
"version": "6.2.10-dev.63",
|
|
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.2.10-dev.
|
|
67
|
+
"mikro-orm": "6.2.10-dev.63",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -47,5 +47,5 @@ export declare class ChangeSetPersister {
|
|
|
47
47
|
* No need to handle composite keys here as they need to be set upfront.
|
|
48
48
|
* We do need to map to the change set payload too, as it will be used in the originalEntityData for new entities.
|
|
49
49
|
*/
|
|
50
|
-
mapReturnedValues<T extends object>(entity: T, payload: EntityDictionary<T>, row: Dictionary | undefined, meta: EntityMetadata<T>, upsert?: boolean): void;
|
|
50
|
+
mapReturnedValues<T extends object>(entity: T | null | undefined, payload: EntityDictionary<T>, row: Dictionary | undefined, meta: EntityMetadata<T>, upsert?: boolean): void;
|
|
51
51
|
}
|
|
@@ -354,7 +354,9 @@ class ChangeSetPersister {
|
|
|
354
354
|
mapReturnedValues(entity, payload, row, meta, upsert = false) {
|
|
355
355
|
if ((this.usesReturningStatement || upsert) && row && utils_1.Utils.hasObjectKeys(row)) {
|
|
356
356
|
const mapped = this.comparator.mapResult(meta.className, row);
|
|
357
|
-
|
|
357
|
+
if (entity) {
|
|
358
|
+
this.hydrator.hydrate(entity, meta, mapped, this.factory, 'full', false, true);
|
|
359
|
+
}
|
|
358
360
|
Object.assign(payload, mapped); // merge to the changeset payload, so it gets saved to the entity snapshot
|
|
359
361
|
}
|
|
360
362
|
}
|