@mikro-orm/core 7.1.13-dev.0 → 7.1.13-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.
@@ -451,10 +451,13 @@ export class MetadataDiscovery {
451
451
  initManyToOneFieldName(prop, name) {
452
452
  const meta2 = prop.targetMeta;
453
453
  const ret = [];
454
- for (const primaryKey of meta2.primaryKeys) {
455
- this.initFieldName(meta2.properties[primaryKey]);
456
- for (const fieldName of meta2.properties[primaryKey].fieldNames) {
457
- ret.push(this.#namingStrategy.joinKeyColumnName(name, fieldName, meta2.compositePK));
454
+ // with `targetKey` on a composite PK target, derive the FK field name from that property
455
+ // instead of the PKs (simple PK targets keep the PK based naming for backwards compatibility)
456
+ const referencedKeys = prop.targetKey && meta2.compositePK ? [prop.targetKey] : meta2.primaryKeys;
457
+ for (const referencedKey of referencedKeys) {
458
+ this.initFieldName(meta2.properties[referencedKey]);
459
+ for (const fieldName of meta2.properties[referencedKey].fieldNames) {
460
+ ret.push(this.#namingStrategy.joinKeyColumnName(name, fieldName, !prop.targetKey && meta2.compositePK));
458
461
  }
459
462
  }
460
463
  return ret;
@@ -2075,6 +2078,7 @@ export class MetadataDiscovery {
2075
2078
  prop.columnTypes.push(...columnTypes);
2076
2079
  if (!targetMeta.compositePK || prop.targetKey) {
2077
2080
  prop.customType = referencedProp.customType;
2081
+ prop.collation ??= referencedProp.collation;
2078
2082
  }
2079
2083
  }
2080
2084
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.1.13-dev.0",
3
+ "version": "7.1.13-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
  "keywords": [
6
6
  "data-mapper",
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.13-dev.0';
156
+ static #ORM_VERSION = '7.1.13-dev.2';
157
157
  /**
158
158
  * Checks if the argument is instance of `Object`. Returns false for arrays.
159
159
  */