@mikro-orm/core 7.1.9-dev.12 → 7.1.9-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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.1.9-dev.
|
|
3
|
+
"version": "7.1.9-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",
|
|
@@ -3,7 +3,7 @@ import { PolymorphicRef } from '../entity/PolymorphicRef.js';
|
|
|
3
3
|
import { helper } from '../entity/wrap.js';
|
|
4
4
|
import { ChangeSetType } from './ChangeSet.js';
|
|
5
5
|
import { isRaw } from '../utils/RawQueryFragment.js';
|
|
6
|
-
import { Utils } from '../utils/Utils.js';
|
|
6
|
+
import { equals, Utils } from '../utils/Utils.js';
|
|
7
7
|
import { OptimisticLockError, ValidationError } from '../errors.js';
|
|
8
8
|
import { ReferenceKind } from '../enums.js';
|
|
9
9
|
/** @internal Executes change sets against the database, handling inserts, updates, and deletes. */
|
|
@@ -338,7 +338,8 @@ export class ChangeSetPersister {
|
|
|
338
338
|
});
|
|
339
339
|
const res = await this.#driver.find(meta.root.class, { $or }, options);
|
|
340
340
|
if (res.length !== changeSets.length) {
|
|
341
|
-
|
|
341
|
+
// a FK pointing to a composite PK is an array, so the values need to be compared deeply
|
|
342
|
+
const compare = (a, b, keys) => keys.every(k => equals(a[k], b[k]));
|
|
342
343
|
const entity = changeSets.find(cs => {
|
|
343
344
|
return !res.some(row => compare(Utils.getPrimaryKeyCond(cs.entity, primaryKeys), row, primaryKeys));
|
|
344
345
|
}).entity;
|
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.1.9-dev.
|
|
156
|
+
static #ORM_VERSION = '7.1.9-dev.13';
|
|
157
157
|
/**
|
|
158
158
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
159
159
|
*/
|
|
@@ -462,7 +462,9 @@ export class Utils {
|
|
|
462
462
|
}
|
|
463
463
|
static getPrimaryKeyCond(entity, primaryKeys) {
|
|
464
464
|
const cond = primaryKeys.reduce((o, pk) => {
|
|
465
|
-
|
|
465
|
+
const value = entity[pk];
|
|
466
|
+
// FKs pointing to a composite PK are arrays, which `extractPK` rejects
|
|
467
|
+
o[pk] = Utils.isPrimaryKey(value, true) ? value : Utils.extractPK(value);
|
|
466
468
|
return o;
|
|
467
469
|
}, {});
|
|
468
470
|
if (Object.values(cond).some(v => v === null)) {
|