@mikro-orm/knex 6.1.12-dev.9 → 6.1.12
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.1.12
|
|
3
|
+
"version": "6.1.12",
|
|
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",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"sqlstring": "2.3.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@mikro-orm/core": "^6.1.
|
|
66
|
+
"@mikro-orm/core": "^6.1.12"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.
|
|
69
|
+
"@mikro-orm/core": "^6.0.0"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -465,7 +465,7 @@ class DatabaseTable {
|
|
|
465
465
|
}
|
|
466
466
|
getForeignKeyDeclaration(fk, namingStrategy, schemaHelper, fkIndex, nullable, propNameBase) {
|
|
467
467
|
const prop = this.getPropertyName(namingStrategy, propNameBase, fk);
|
|
468
|
-
const kind = (fkIndex
|
|
468
|
+
const kind = (fkIndex?.unique && !fkIndex.primary) ? this.getReferenceKind(fk, fkIndex) : this.getReferenceKind(fk);
|
|
469
469
|
const type = this.getPropertyTypeForForeignKey(namingStrategy, fk);
|
|
470
470
|
const fkOptions = {};
|
|
471
471
|
fkOptions.fieldNames = fk.columnNames;
|
|
@@ -497,9 +497,9 @@ class DatabaseTable {
|
|
|
497
497
|
kind,
|
|
498
498
|
...columnOptions,
|
|
499
499
|
nullable,
|
|
500
|
-
primary: fkIndex
|
|
501
|
-
index: !fkIndex
|
|
502
|
-
unique: (fkIndex
|
|
500
|
+
primary: fkIndex?.primary || !fk.columnNames.some(columnName => !this.getPrimaryKey()?.columnNames.includes(columnName)),
|
|
501
|
+
index: !fkIndex?.unique ? fkIndex?.keyName : undefined,
|
|
502
|
+
unique: (fkIndex?.unique && !fkIndex.primary) ? fkIndex.keyName : undefined,
|
|
503
503
|
...fkOptions,
|
|
504
504
|
};
|
|
505
505
|
}
|
package/schema/SchemaHelper.js
CHANGED
|
@@ -187,8 +187,12 @@ class SchemaHelper {
|
|
|
187
187
|
mapForeignKeys(fks, tableName, schemaName) {
|
|
188
188
|
return fks.reduce((ret, fk) => {
|
|
189
189
|
if (ret[fk.constraint_name]) {
|
|
190
|
-
ret[fk.constraint_name].columnNames.
|
|
191
|
-
|
|
190
|
+
if (!ret[fk.constraint_name].columnNames.includes(fk.column_name)) {
|
|
191
|
+
ret[fk.constraint_name].columnNames.push(fk.column_name);
|
|
192
|
+
}
|
|
193
|
+
if (!ret[fk.constraint_name].referencedColumnNames.includes(fk.referenced_column_name)) {
|
|
194
|
+
ret[fk.constraint_name].referencedColumnNames.push(fk.referenced_column_name);
|
|
195
|
+
}
|
|
192
196
|
}
|
|
193
197
|
else {
|
|
194
198
|
ret[fk.constraint_name] = {
|