@mikro-orm/knex 6.4.7-dev.17 → 6.4.7-dev.19
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.
|
@@ -59,12 +59,15 @@ class MsSqlQueryCompiler extends MonkeyPatchable_1.MonkeyPatchable.MsSqlQueryCom
|
|
|
59
59
|
|| (typeof insert === 'object' && core_1.Utils.isEmpty(insert));
|
|
60
60
|
}
|
|
61
61
|
_mergeOn(conflict) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const conflictColumn = this.formatter.columnize(conflict[0]);
|
|
65
|
-
sql = `on ${this.tableName}.${conflictColumn} = tsource.${conflictColumn}`;
|
|
62
|
+
if (!Array.isArray(conflict)) {
|
|
63
|
+
return 'on 1=1';
|
|
66
64
|
}
|
|
67
|
-
|
|
65
|
+
const parts = [];
|
|
66
|
+
for (const col of conflict) {
|
|
67
|
+
const conflictColumn = this.formatter.columnize(col);
|
|
68
|
+
parts.push(`${this.tableName}.${conflictColumn} = tsource.${conflictColumn}`);
|
|
69
|
+
}
|
|
70
|
+
return `on ${parts.join(' and ')}`;
|
|
68
71
|
}
|
|
69
72
|
_insertWithMerge() {
|
|
70
73
|
const { insert = [], onConflict, ignore, merge, returning, options = {} } = this.single;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.4.7-dev.
|
|
3
|
+
"version": "6.4.7-dev.19",
|
|
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.4.6"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.4.7-dev.
|
|
69
|
+
"@mikro-orm/core": "6.4.7-dev.19",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/query/CriteriaNode.js
CHANGED
|
@@ -72,16 +72,12 @@ class CriteriaNode {
|
|
|
72
72
|
let joinAlias = qb.getAliasForJoinPath(this.getPath());
|
|
73
73
|
if (!joinAlias && this.parent && [core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.ONE_TO_ONE].includes(this.prop.kind) && this.prop.owner) {
|
|
74
74
|
joinAlias = qb.getAliasForJoinPath(this.parent.getPath());
|
|
75
|
-
return core_1.Utils.getPrimaryKeyHash(this.prop.
|
|
75
|
+
return core_1.Utils.getPrimaryKeyHash(this.prop.ownColumns.map(col => `${joinAlias ?? qb.alias}.${col}`));
|
|
76
76
|
}
|
|
77
77
|
const alias = joinAlias ?? qb.alias;
|
|
78
78
|
if (this.prop.kind === core_1.ReferenceKind.MANY_TO_MANY) {
|
|
79
79
|
return core_1.Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map(col => `${alias}.${col}`));
|
|
80
80
|
}
|
|
81
|
-
// if we found a matching join, we need to use the target table column names, as we use that alias instead of the root
|
|
82
|
-
if (!joinAlias && this.prop.owner && this.prop.joinColumns.length > 1) {
|
|
83
|
-
return core_1.Utils.getPrimaryKeyHash(this.prop.joinColumns.map(col => `${alias}.${col}`));
|
|
84
|
-
}
|
|
85
81
|
return core_1.Utils.getPrimaryKeyHash(this.prop.referencedColumnNames.map(col => `${alias}.${col}`));
|
|
86
82
|
}
|
|
87
83
|
getPath(addIndex = false) {
|
|
@@ -43,9 +43,6 @@ class QueryBuilderHelper {
|
|
|
43
43
|
const prop = this.getProperty(f, a);
|
|
44
44
|
const fkIdx2 = prop?.fieldNames.findIndex(name => name === f) ?? -1;
|
|
45
45
|
if (fkIdx2 !== -1) {
|
|
46
|
-
if (prop?.ownColumns && !prop.ownColumns.includes(f)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
46
|
parts.push(this.mapper(a !== this.alias ? `${a}.${prop.fieldNames[fkIdx2]}` : prop.fieldNames[fkIdx2], type, value, alias));
|
|
50
47
|
}
|
|
51
48
|
else if (prop) {
|
|
@@ -66,9 +63,6 @@ class QueryBuilderHelper {
|
|
|
66
63
|
}
|
|
67
64
|
});
|
|
68
65
|
}
|
|
69
|
-
if (parts.length === 1) {
|
|
70
|
-
return parts[0];
|
|
71
|
-
}
|
|
72
66
|
return this.knex.raw('(' + parts.map(part => this.knex.ref(part)).join(', ') + ')');
|
|
73
67
|
}
|
|
74
68
|
const rawField = core_1.RawQueryFragment.getKnownFragment(field);
|