@mikro-orm/core 6.6.18-dev.1 → 6.6.18-dev.2

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": "6.6.18-dev.1",
3
+ "version": "6.6.18-dev.2",
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.3",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.6.18-dev.1",
67
+ "mikro-orm": "6.6.18-dev.2",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -161,7 +161,8 @@ class EntityComparator {
161
161
  const lines = [];
162
162
  const context = new Map();
163
163
  context.set('isEntityOrRef', (val) => Utils_1.Utils.isEntity(val, true));
164
- context.set('getCompositeKeyValue', (val) => Utils_1.Utils.flatten(Utils_1.Utils.getCompositeKeyValue(val, meta, 'convertToDatabaseValue', this.platform)));
164
+ // deep flatten, nested composite PKs produce nested arrays that would be comma-joined by the hash
165
+ context.set('getCompositeKeyValue', (val) => Utils_1.Utils.flatten(Utils_1.Utils.getCompositeKeyValue(val, meta, 'convertToDatabaseValue', this.platform), true));
165
166
  context.set('getPrimaryKeyHash', (val) => Utils_1.Utils.getPrimaryKeyHash(Utils_1.Utils.asArray(val)));
166
167
  if (meta.primaryKeys.length > 1) {
167
168
  lines.push(` const pks = entity.__helper.__pk ? getCompositeKeyValue(entity.__helper.__pk) : [`);
package/utils/Utils.js CHANGED
@@ -503,7 +503,8 @@ class Utils {
503
503
  static getCompositeKeyHash(data, meta, convertCustomTypes = false, platform, flat = false) {
504
504
  let pks = this.getCompositeKeyValue(data, meta, convertCustomTypes, platform);
505
505
  if (flat) {
506
- pks = Utils.flatten(pks);
506
+ // deep flatten, nested composite PKs produce nested arrays that would be comma-joined by the hash
507
+ pks = Utils.flatten(pks, true);
507
508
  }
508
509
  return Utils.getPrimaryKeyHash(pks);
509
510
  }