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

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.
@@ -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.13",
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.13"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"