@mikro-orm/core 7.0.7-dev.13 → 7.0.7-dev.15

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.
@@ -706,6 +706,9 @@ type MaybeScalarRef<Value, Options> = Options extends {
706
706
  } ? Value : Options extends {
707
707
  ref: true;
708
708
  } ? ScalarReference<Value> : Value;
709
+ type IsAllPropsOpt<T> = [Exclude<keyof T, symbol>] extends [never] ? false : {
710
+ [K in Exclude<keyof T, symbol>]-?: T[K] extends Opt ? never : K;
711
+ }[Exclude<keyof T, symbol>] extends never ? true : false;
709
712
  type MaybeOpt<Value, Options> = Options extends {
710
713
  mapToPk: true;
711
714
  } ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Options extends {
@@ -722,7 +725,9 @@ type MaybeOpt<Value, Options> = Options extends {
722
725
  version: true;
723
726
  } | {
724
727
  formula: string | ((...args: any[]) => any);
725
- } ? Opt<NonNullable<Value>> | Extract<Value, null | undefined> : Value;
728
+ } ? Opt<NonNullable<Value>> | Extract<Value, null | undefined> : Options extends {
729
+ kind: 'embedded';
730
+ } ? IsAllPropsOpt<Value> extends true ? Opt<NonNullable<Value>> | Extract<Value, null | undefined> : Value : Value;
726
731
  type MaybeHidden<Value, Options> = Options extends {
727
732
  hidden: true;
728
733
  } ? Hidden<NonNullable<Value>> | Extract<Value, null | undefined> : Value;
@@ -428,13 +428,13 @@ export class MetadataDiscovery {
428
428
  prop.fieldNames = this.initManyToManyFieldName(prop, prop.name);
429
429
  }
430
430
  }
431
- initManyToOneFieldName(prop, name, tableName) {
431
+ initManyToOneFieldName(prop, name) {
432
432
  const meta2 = prop.targetMeta;
433
433
  const ret = [];
434
434
  for (const primaryKey of meta2.primaryKeys) {
435
435
  this.initFieldName(meta2.properties[primaryKey]);
436
436
  for (const fieldName of meta2.properties[primaryKey].fieldNames) {
437
- ret.push(this.#namingStrategy.joinKeyColumnName(name, fieldName, meta2.compositePK, tableName));
437
+ ret.push(this.#namingStrategy.joinKeyColumnName(name, fieldName, meta2.compositePK));
438
438
  }
439
439
  }
440
440
  return ret;
@@ -487,11 +487,9 @@ export class MetadataDiscovery {
487
487
  prop.joinColumns ??= prop.referencedColumnNames.map(referencedColumnName => this.#namingStrategy.joinKeyColumnName(prop.discriminator, referencedColumnName, prop.referencedColumnNames.length > 1));
488
488
  }
489
489
  else {
490
- const ownerTableName = this.isExplicitTableName(meta.root) ? meta.root.tableName : undefined;
491
- prop.joinColumns ??= prop.referencedColumnNames.map(referencedColumnName => this.#namingStrategy.joinKeyColumnName(meta.root.className, referencedColumnName, meta.compositePK, ownerTableName));
490
+ prop.joinColumns ??= prop.referencedColumnNames.map(referencedColumnName => this.#namingStrategy.joinKeyColumnName(meta.root.className, referencedColumnName, meta.compositePK));
492
491
  }
493
- const inverseTableName = this.isExplicitTableName(meta2.root) ? meta2.root.tableName : undefined;
494
- prop.inverseJoinColumns ??= this.initManyToOneFieldName(prop, meta2.root.className, inverseTableName);
492
+ prop.inverseJoinColumns ??= this.initManyToOneFieldName(prop, meta2.root.className);
495
493
  }
496
494
  isExplicitTableName(meta) {
497
495
  return meta.tableName !== this.#namingStrategy.classToTableName(meta.className);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.7-dev.13",
3
+ "version": "7.0.7-dev.15",
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",
@@ -101,6 +101,8 @@ export class ChangeSetPersister {
101
101
  !prop.generated &&
102
102
  !prop.embedded &&
103
103
  ![ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind) &&
104
+ !(prop.kind === ReferenceKind.EMBEDDED &&
105
+ prop.targetMeta?.props.every(p => p.formula || p.persist === false || p.primary)) &&
104
106
  prop.name !== wrapped.__meta.root.discriminatorColumn &&
105
107
  prop.type !== 'ObjectId' &&
106
108
  prop.persist !== false &&
package/utils/Utils.js CHANGED
@@ -132,7 +132,7 @@ export function parseJsonSafe(value) {
132
132
  /** Collection of general-purpose utility methods used throughout the ORM. */
133
133
  export class Utils {
134
134
  static PK_SEPARATOR = '~~~';
135
- static #ORM_VERSION = '7.0.7-dev.13';
135
+ static #ORM_VERSION = '7.0.7-dev.15';
136
136
  /**
137
137
  * Checks if the argument is instance of `Object`. Returns false for arrays.
138
138
  */