@mikro-orm/knex 6.6.5-dev.1 → 6.6.5-dev.3
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/AbstractSqlDriver.js +11 -1
- package/package.json +2 -2
package/AbstractSqlDriver.js
CHANGED
|
@@ -368,7 +368,8 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
368
368
|
const set = new Set();
|
|
369
369
|
data.forEach(row => core_1.Utils.keys(row).forEach(k => set.add(k)));
|
|
370
370
|
const props = [...set].map(name => meta?.properties[name] ?? { name, fieldNames: [name] });
|
|
371
|
-
|
|
371
|
+
// For STI with conflicting fieldNames, include all alternative columns
|
|
372
|
+
let fields = core_1.Utils.flatten(props.map(prop => prop.stiFieldNames ?? prop.fieldNames));
|
|
372
373
|
const duplicates = core_1.Utils.findDuplicates(fields);
|
|
373
374
|
const params = [];
|
|
374
375
|
if (duplicates.length) {
|
|
@@ -425,6 +426,15 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
425
426
|
const keys = [];
|
|
426
427
|
const usedDups = [];
|
|
427
428
|
props.forEach(prop => {
|
|
429
|
+
// For STI with conflicting fieldNames, use discriminator to determine which field gets value
|
|
430
|
+
if (prop.stiFieldNames && prop.stiFieldNameMap && meta?.discriminatorColumn) {
|
|
431
|
+
const activeField = prop.stiFieldNameMap[row[meta.discriminatorColumn]];
|
|
432
|
+
for (const field of prop.stiFieldNames) {
|
|
433
|
+
params.push(field === activeField ? row[prop.name] : null);
|
|
434
|
+
keys.push('?');
|
|
435
|
+
}
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
428
438
|
if (prop.fieldNames.length > 1) {
|
|
429
439
|
const newFields = [];
|
|
430
440
|
const allParam = [...core_1.Utils.asArray(row[prop.name]) ?? prop.fieldNames.map(() => null)];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.6.5-dev.
|
|
3
|
+
"version": "6.6.5-dev.3",
|
|
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.6.4"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.6.5-dev.
|
|
69
|
+
"@mikro-orm/core": "6.6.5-dev.3",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|