@mikro-orm/core 7.0.16-dev.11 → 7.0.16-dev.13
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 +9 -1
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/EntityManager.js
CHANGED
|
@@ -806,7 +806,10 @@ export class EntityManager {
|
|
|
806
806
|
data = QueryHelper.processObjectParams(data);
|
|
807
807
|
validateParams(data, 'insert data');
|
|
808
808
|
if (em.eventManager.hasListeners(EventType.beforeUpsert, meta)) {
|
|
809
|
-
await em.eventManager.dispatchEvent(EventType.beforeUpsert, { entity: data, em, meta }, meta);
|
|
809
|
+
await em.eventManager.dispatchEvent(EventType.beforeUpsert, { entity: entity ?? data, em, meta }, meta);
|
|
810
|
+
if (entity) {
|
|
811
|
+
data = em.#comparator.prepareEntity(entity);
|
|
812
|
+
}
|
|
810
813
|
}
|
|
811
814
|
const ret = await em.driver.nativeUpdate(entityName, where, data, {
|
|
812
815
|
ctx: em.#transactionContext,
|
|
@@ -921,6 +924,7 @@ export class EntityManager {
|
|
|
921
924
|
const allWhere = [];
|
|
922
925
|
const entities = new Map();
|
|
923
926
|
const entitiesByData = new Map();
|
|
927
|
+
const entitiesByAllDataIdx = new Map();
|
|
924
928
|
for (let i = 0; i < data.length; i++) {
|
|
925
929
|
let row = data[i];
|
|
926
930
|
let where;
|
|
@@ -934,6 +938,7 @@ export class EntityManager {
|
|
|
934
938
|
}
|
|
935
939
|
where = helper(entity).getPrimaryKey();
|
|
936
940
|
em.#entityFactory.assignDefaultValues(entity, meta);
|
|
941
|
+
entitiesByAllDataIdx.set(allData.length, entity);
|
|
937
942
|
row = em.#comparator.prepareEntity(entity);
|
|
938
943
|
}
|
|
939
944
|
else {
|
|
@@ -981,6 +986,9 @@ export class EntityManager {
|
|
|
981
986
|
const entity = entitiesByData.get(dto) ?? dto;
|
|
982
987
|
await em.eventManager.dispatchEvent(EventType.beforeUpsert, { entity, em, meta }, meta);
|
|
983
988
|
}
|
|
989
|
+
for (const [idx, entity] of entitiesByAllDataIdx) {
|
|
990
|
+
allData[idx] = em.#comparator.prepareEntity(entity);
|
|
991
|
+
}
|
|
984
992
|
}
|
|
985
993
|
const res = await em.driver.nativeUpdateMany(entityName, allWhere, allData, {
|
|
986
994
|
ctx: em.#transactionContext,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.16-dev.
|
|
3
|
+
"version": "7.0.16-dev.13",
|
|
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/utils/Utils.js
CHANGED
|
@@ -141,7 +141,7 @@ export function parseJsonSafe(value) {
|
|
|
141
141
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
142
142
|
export class Utils {
|
|
143
143
|
static PK_SEPARATOR = '~~~';
|
|
144
|
-
static #ORM_VERSION = '7.0.16-dev.
|
|
144
|
+
static #ORM_VERSION = '7.0.16-dev.13';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|