@mikro-orm/knex 6.5.10-dev.19 → 6.5.10-dev.20
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.
- package/package.json +2 -2
- package/schema/DatabaseTable.js +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.5.10-dev.
|
|
3
|
+
"version": "6.5.10-dev.20",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@mikro-orm/core": "^6.5.9"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.5.10-dev.
|
|
69
|
+
"@mikro-orm/core": "6.5.10-dev.20",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -614,7 +614,7 @@ class DatabaseTable {
|
|
|
614
614
|
fkOptions.deferMode = fk.deferMode;
|
|
615
615
|
fkOptions.columnTypes = fk.columnNames.map(col => this.getColumn(col).type);
|
|
616
616
|
}
|
|
617
|
-
|
|
617
|
+
const ret = {
|
|
618
618
|
name: prop,
|
|
619
619
|
type,
|
|
620
620
|
runtimeType,
|
|
@@ -642,6 +642,11 @@ class DatabaseTable {
|
|
|
642
642
|
persist,
|
|
643
643
|
...fkOptions,
|
|
644
644
|
};
|
|
645
|
+
const nativeEnumName = Object.keys(this.nativeEnums).find(name => name === column.type);
|
|
646
|
+
if (nativeEnumName) {
|
|
647
|
+
ret.nativeEnumName = nativeEnumName;
|
|
648
|
+
}
|
|
649
|
+
return ret;
|
|
645
650
|
}
|
|
646
651
|
getReferenceKind(fk, unique) {
|
|
647
652
|
if (fk && unique) {
|
|
@@ -678,12 +683,14 @@ class DatabaseTable {
|
|
|
678
683
|
const enumMode = this.platform.getConfig().get('entityGenerator').enumMode;
|
|
679
684
|
// If this column is using an enum.
|
|
680
685
|
if (column.enumItems?.length) {
|
|
686
|
+
const name = column.nativeEnumName ?? column.name;
|
|
687
|
+
const tableName = column.nativeEnumName ? undefined : this.name;
|
|
681
688
|
if (enumMode === 'ts-enum') {
|
|
682
689
|
// We will create a new enum name for this type and set it as the property type as well.
|
|
683
|
-
return namingStrategy.getEnumClassName(
|
|
690
|
+
return namingStrategy.getEnumClassName(name, tableName, this.schema);
|
|
684
691
|
}
|
|
685
692
|
// With other enum strategies, we need to use the type name.
|
|
686
|
-
return namingStrategy.getEnumTypeName(
|
|
693
|
+
return namingStrategy.getEnumTypeName(name, tableName, this.schema);
|
|
687
694
|
}
|
|
688
695
|
return column.mappedType?.runtimeType ?? 'unknown';
|
|
689
696
|
}
|