@mikro-orm/core 6.5.10-dev.28 → 6.5.10-dev.29

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.5.10-dev.28",
3
+ "version": "6.5.10-dev.29",
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.2",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.5.10-dev.28",
67
+ "mikro-orm": "6.5.10-dev.29",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -420,11 +420,21 @@ class EntityComparator {
420
420
  }
421
421
  getEmbeddedPropertySnapshot(meta, prop, context, level, path, dataKey, object = prop.object) {
422
422
  const padding = ' '.repeat(level * 2);
423
+ const nullCond = `entity${path.map(k => this.wrap(k)).join('')} === null`;
423
424
  let ret = `${level === 1 ? '' : '\n'}`;
424
425
  if (object) {
425
- const nullCond = `entity${path.map(k => this.wrap(k)).join('')} === null`;
426
426
  ret += `${padding}if (${nullCond}) ret${dataKey} = null;\n`;
427
427
  }
428
+ else {
429
+ ret += `${padding}if (${nullCond}) {\n`;
430
+ ret += meta.props.filter(p => p.embedded?.[0] === prop.name
431
+ // object for JSON embeddable
432
+ && (p.object || (p.persist !== false))).map(childProp => {
433
+ const childDataKey = meta.embeddable || prop.object ? dataKey + this.wrap(childProp.embedded[1]) : this.wrap(childProp.name);
434
+ return `${padding} ret${childDataKey} = null;`;
435
+ }).join('\n') + `\n`;
436
+ ret += `${padding}}\n`;
437
+ }
428
438
  const cond = `entity${path.map(k => this.wrap(k)).join('')} != null`;
429
439
  ret += `${padding}if (${cond}) {\n`;
430
440
  if (object) {