@mikro-orm/knex 6.4.17-dev.88 → 6.4.17-dev.89
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/query/QueryBuilder.js +11 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.4.17-dev.
|
|
3
|
+
"version": "6.4.17-dev.89",
|
|
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.16"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.4.17-dev.
|
|
69
|
+
"@mikro-orm/core": "6.4.17-dev.89",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/query/QueryBuilder.js
CHANGED
|
@@ -189,10 +189,10 @@ class QueryBuilder {
|
|
|
189
189
|
subquery = field[1] instanceof QueryBuilder ? field[1].getFormattedQuery() : field[1].toString();
|
|
190
190
|
field = field[0];
|
|
191
191
|
}
|
|
192
|
-
const prop = this.joinReference(field, alias, cond, type, path, schema, subquery);
|
|
192
|
+
const { prop, key } = this.joinReference(field, alias, cond, type, path, schema, subquery);
|
|
193
193
|
const [fromAlias] = this.helper.splitField(field);
|
|
194
194
|
if (subquery) {
|
|
195
|
-
this._joins[
|
|
195
|
+
this._joins[key].subquery = subquery;
|
|
196
196
|
}
|
|
197
197
|
const populate = this._joinedProps.get(fromAlias);
|
|
198
198
|
const item = { field: prop.name, strategy: core_1.LoadStrategy.JOINED, children: [] };
|
|
@@ -927,7 +927,8 @@ class QueryBuilder {
|
|
|
927
927
|
prop.targetMeta = field.mainAlias.metadata;
|
|
928
928
|
field = field.getKnexQuery();
|
|
929
929
|
}
|
|
930
|
-
|
|
930
|
+
const key = `${this.alias}.${prop.name}#${alias}`;
|
|
931
|
+
this._joins[key] = {
|
|
931
932
|
prop,
|
|
932
933
|
alias,
|
|
933
934
|
type,
|
|
@@ -936,7 +937,7 @@ class QueryBuilder {
|
|
|
936
937
|
subquery: field.toString(),
|
|
937
938
|
ownerAlias: this.alias,
|
|
938
939
|
};
|
|
939
|
-
return prop;
|
|
940
|
+
return { prop, key };
|
|
940
941
|
}
|
|
941
942
|
if (!subquery && type.includes('lateral')) {
|
|
942
943
|
throw new Error(`Lateral join can be used only with a sub-query.`);
|
|
@@ -965,6 +966,7 @@ class QueryBuilder {
|
|
|
965
966
|
path ??= `${(Object.values(this._joins).find(j => j.alias === fromAlias)?.path ?? entityName)}.${prop.name}`;
|
|
966
967
|
if (prop.kind === core_1.ReferenceKind.ONE_TO_MANY) {
|
|
967
968
|
this._joins[aliasedName] = this.helper.joinOneToReference(prop, fromAlias, alias, type, cond, schema);
|
|
969
|
+
this._joins[aliasedName].path ??= path;
|
|
968
970
|
}
|
|
969
971
|
else if (prop.kind === core_1.ReferenceKind.MANY_TO_MANY) {
|
|
970
972
|
let pivotAlias = alias;
|
|
@@ -976,17 +978,18 @@ class QueryBuilder {
|
|
|
976
978
|
const joins = this.helper.joinManyToManyReference(prop, fromAlias, alias, pivotAlias, type, cond, path, schema);
|
|
977
979
|
Object.assign(this._joins, joins);
|
|
978
980
|
this.createAlias(prop.pivotEntity, pivotAlias);
|
|
981
|
+
this._joins[aliasedName].path ??= path;
|
|
982
|
+
aliasedName = Object.keys(joins)[1];
|
|
979
983
|
}
|
|
980
984
|
else if (prop.kind === core_1.ReferenceKind.ONE_TO_ONE) {
|
|
981
985
|
this._joins[aliasedName] = this.helper.joinOneToReference(prop, fromAlias, alias, type, cond, schema);
|
|
986
|
+
this._joins[aliasedName].path ??= path;
|
|
982
987
|
}
|
|
983
988
|
else { // MANY_TO_ONE
|
|
984
989
|
this._joins[aliasedName] = this.helper.joinManyToOneReference(prop, fromAlias, alias, type, cond, schema);
|
|
990
|
+
this._joins[aliasedName].path ??= path;
|
|
985
991
|
}
|
|
986
|
-
|
|
987
|
-
this._joins[aliasedName].path = path;
|
|
988
|
-
}
|
|
989
|
-
return prop;
|
|
992
|
+
return { prop, key: aliasedName };
|
|
990
993
|
}
|
|
991
994
|
prepareFields(fields, type = 'where') {
|
|
992
995
|
const ret = [];
|