@mikro-orm/core 7.2.5-dev.6 → 7.2.5-dev.8

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.
@@ -1626,7 +1626,7 @@ export class MetadataDiscovery {
1626
1626
  if (meta.inheritanceType !== 'tpt') {
1627
1627
  return;
1628
1628
  }
1629
- const belongsToTable = (prop) => prop.persist !== false || prop.primary;
1629
+ const belongsToTable = (prop) => prop.persist !== false || prop.primary || !!prop.formula;
1630
1630
  // Use meta.properties (object) since meta.props (array) may not be populated yet
1631
1631
  const allProps = Object.values(meta.properties);
1632
1632
  if (!meta.tptParent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.5-dev.6",
3
+ "version": "7.2.5-dev.8",
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",
@@ -44,7 +44,8 @@ export class CommitOrderCalculator {
44
44
  if (!toOneOwner && !toManyOwner) {
45
45
  return;
46
46
  }
47
- const propertyType = prop.targetMeta?.root._id;
47
+ // TPT tables are separate nodes and the FK references the target's own table, not the root
48
+ const propertyType = (prop.targetMeta?.inheritanceType === 'tpt' ? prop.targetMeta : prop.targetMeta?.root)?._id;
48
49
  if (propertyType == null || !this.hasNode(propertyType)) {
49
50
  return;
50
51
  }
@@ -1283,6 +1283,13 @@ export class UnitOfWork {
1283
1283
  calc.discoverProperty({ ...prop, targetMeta }, meta._id);
1284
1284
  }
1285
1285
  }
1286
+ else if (prop.targetMeta?.inheritanceType === 'tpt') {
1287
+ calc.discoverProperty(prop, meta._id);
1288
+ // a TPT subclass delete has only a leaf change set that also removes the target row; weak edge so it can't break insert order
1289
+ for (const targetMeta of this.#metadata.find(prop.targetMeta.class).allTPTDescendants ?? []) {
1290
+ calc.discoverProperty({ ...prop, targetMeta, nullable: true }, meta._id);
1291
+ }
1292
+ }
1286
1293
  else {
1287
1294
  calc.discoverProperty(prop, meta._id);
1288
1295
  }
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.2.5-dev.6';
156
+ static #ORM_VERSION = '7.2.5-dev.8';
157
157
  /** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
158
158
  static getRlsSettingName(filterName, argName) {
159
159
  return `mikro.${filterName}.${argName}`;