@mikro-orm/sql 7.0.3-dev.12 → 7.0.3-dev.14

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.
@@ -1521,13 +1521,10 @@ export class AbstractSqlDriver extends DatabaseDriver {
1521
1521
  childAliases[childMeta.className] = childAlias;
1522
1522
  qb.addPropertyJoin(childMeta.tptInverseProp, baseAlias, childAlias, JoinType.leftJoin, `[tpt]${meta.className}`);
1523
1523
  // Add fields from this child (only ownProps, skip PKs)
1524
- for (const prop of childMeta.ownProps.filter(p => !p.primary && this.platform.shouldHaveColumn(p, []))) {
1525
- for (const fieldName of prop.fieldNames) {
1526
- const field = `${childAlias}.${fieldName}`;
1527
- const fieldAlias = `${childAlias}__${fieldName}`;
1528
- fields.push(raw(`${this.platform.quoteIdentifier(field)} as ${this.platform.quoteIdentifier(fieldAlias)}`));
1529
- }
1530
- }
1524
+ const schema = childMeta.schema === '*' ? '*' : this.getSchemaName(childMeta);
1525
+ childMeta
1526
+ .ownProps.filter(p => !p.primary && this.platform.shouldHaveColumn(p, []))
1527
+ .forEach(prop => fields.push(...this.mapPropToFieldNames(qb, prop, childAlias, childMeta, schema)));
1531
1528
  }
1532
1529
  // Add computed discriminator (descendants already sorted by depth)
1533
1530
  if (meta.root.tptDiscriminatorColumn) {
@@ -311,10 +311,32 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
311
311
  : undefined,
312
312
  comment: col.column_comment,
313
313
  };
314
- if (nativeEnums?.[column.type]) {
314
+ let enumKey = column.type;
315
+ let enumEntry = nativeEnums?.[enumKey];
316
+ // for array enum columns, strip the [] suffix and try the base type,
317
+ // try schema-qualified key first for non-default schemas to avoid
318
+ // ambiguity when multiple schemas have enums with the same name
319
+ if (!enumEntry && enumKey.endsWith('[]')) {
320
+ const baseType = enumKey.slice(0, -2);
321
+ if (col.udt_schema && col.udt_schema !== this.platform.getDefaultSchemaName()) {
322
+ const schemaKey = `${col.udt_schema}.${baseType}`;
323
+ enumEntry = nativeEnums?.[schemaKey];
324
+ if (enumEntry) {
325
+ enumKey = schemaKey;
326
+ column.type = `${schemaKey}[]`;
327
+ }
328
+ }
329
+ if (!enumEntry) {
330
+ enumEntry = nativeEnums?.[baseType];
331
+ if (enumEntry) {
332
+ enumKey = baseType;
333
+ }
334
+ }
335
+ }
336
+ if (enumEntry) {
315
337
  column.mappedType = Type.getType(EnumType);
316
- column.nativeEnumName = column.type;
317
- column.enumItems = nativeEnums[column.type]?.items;
338
+ column.nativeEnumName = enumKey;
339
+ column.enumItems = enumEntry.items;
318
340
  }
319
341
  ret[key].push(column);
320
342
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.0.3-dev.12",
3
+ "version": "7.0.3-dev.14",
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",
@@ -53,7 +53,7 @@
53
53
  "@mikro-orm/core": "^7.0.2"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.0.3-dev.12"
56
+ "@mikro-orm/core": "7.0.3-dev.14"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"