@mikro-orm/knex 6.0.0-dev.310 → 6.0.0-dev.312
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 +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.312",
|
|
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,6 +66,6 @@
|
|
|
66
66
|
"@mikro-orm/core": "^5.0.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.0.0-dev.
|
|
69
|
+
"@mikro-orm/core": "6.0.0-dev.312"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -169,7 +169,7 @@ class DatabaseTable {
|
|
|
169
169
|
const ret = { name: index.keyName };
|
|
170
170
|
// Index is for FK. Map to the FK prop and move on.
|
|
171
171
|
const fkForIndex = fkIndexes.get(index);
|
|
172
|
-
if (fkForIndex) {
|
|
172
|
+
if (fkForIndex && !fkForIndex.fk.columnNames.some(col => !index.columnNames.includes(col))) {
|
|
173
173
|
ret.properties = [this.getPropertyName(namingStrategy, fkForIndex.baseName, fkForIndex.fk)];
|
|
174
174
|
const map = index.unique ? compositeFkUniques : compositeFkIndexes;
|
|
175
175
|
map[ret.properties[0]] = { keyName: index.keyName };
|
|
@@ -348,15 +348,15 @@ class DatabaseTable {
|
|
|
348
348
|
return index.columnNames.length >= fkColumnsLength && !currentFk.columnNames.some((columnName, i) => index.columnNames[i] !== columnName);
|
|
349
349
|
});
|
|
350
350
|
possibleIndexes.sort((a, b) => {
|
|
351
|
+
if (a.columnNames.length !== b.columnNames.length) {
|
|
352
|
+
return a.columnNames.length < b.columnNames.length ? -1 : 1;
|
|
353
|
+
}
|
|
351
354
|
if (a.primary !== b.primary) {
|
|
352
355
|
return a.primary ? -1 : 1;
|
|
353
356
|
}
|
|
354
357
|
if (a.unique !== b.unique) {
|
|
355
358
|
return a.unique ? -1 : 1;
|
|
356
359
|
}
|
|
357
|
-
if (a.columnNames.length !== b.columnNames.length) {
|
|
358
|
-
return a.columnNames.length < b.columnNames.length ? -1 : 1;
|
|
359
|
-
}
|
|
360
360
|
return a.keyName.localeCompare(b.keyName);
|
|
361
361
|
});
|
|
362
362
|
return possibleIndexes[0];
|
|
@@ -522,6 +522,7 @@ class DatabaseTable {
|
|
|
522
522
|
defaultRaw: this.getPropertyDefaultValue(schemaHelper, column, type, true),
|
|
523
523
|
nullable: column.nullable,
|
|
524
524
|
primary: column.primary && persist,
|
|
525
|
+
autoincrement: column.autoincrement,
|
|
525
526
|
fieldName: column.name,
|
|
526
527
|
length: column.length,
|
|
527
528
|
precision: column.precision,
|