@mikro-orm/sql 7.1.5-dev.21 → 7.1.5-dev.23
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 +19 -0
- package/package.json +2 -2
package/AbstractSqlDriver.js
CHANGED
|
@@ -1248,6 +1248,11 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
1248
1248
|
if (owners.length === 0) {
|
|
1249
1249
|
return {};
|
|
1250
1250
|
}
|
|
1251
|
+
// The pivot order is recomputed via `getPivotOrderBy`, so the parent `populateOrderBy` must not leak
|
|
1252
|
+
// into the pivot subquery — its keys reference the parent entity, not the pivot (GH #7910).
|
|
1253
|
+
if (options?.populateOrderBy != null) {
|
|
1254
|
+
options = { ...options, populateOrderBy: undefined };
|
|
1255
|
+
}
|
|
1251
1256
|
const pivotMeta = this.metadata.get(prop.pivotEntity);
|
|
1252
1257
|
if (prop.discriminatorColumn && QueryHelper.isUnionTargetPolymorphic(prop)) {
|
|
1253
1258
|
return this.loadFromUnionTargetPolymorphicPivotTable(prop, owners, where, orderBy, ctx, options, pivotJoin);
|
|
@@ -2209,6 +2214,20 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
2209
2214
|
const join = qb.getJoinForPath(path, { matchPopulateJoins: true });
|
|
2210
2215
|
const propAlias = qb.getAliasForJoinPath(join ?? path, { matchPopulateJoins: true }) ?? parentAlias;
|
|
2211
2216
|
if (!join) {
|
|
2217
|
+
// an owner to-one relation that is not joined (e.g. ordering a populated collection by such
|
|
2218
|
+
// a relation's primary key) can be ordered by its local FK columns, matching the `select-in`
|
|
2219
|
+
// and `balanced` strategies instead of silently dropping the clause
|
|
2220
|
+
if (prop.owner &&
|
|
2221
|
+
[ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) &&
|
|
2222
|
+
Utils.isPlainObject(childOrder)) {
|
|
2223
|
+
for (const childField of Utils.getObjectQueryKeys(childOrder)) {
|
|
2224
|
+
const idx = prop.referencedPKs.indexOf(childField);
|
|
2225
|
+
const order = childOrder[childField];
|
|
2226
|
+
if (idx !== -1 && order) {
|
|
2227
|
+
orderBy.push({ [`${parentAlias}.${prop.joinColumns[idx]}`]: order });
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2212
2231
|
continue;
|
|
2213
2232
|
}
|
|
2214
2233
|
if (join &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.1.5-dev.
|
|
3
|
+
"version": "7.1.5-dev.23",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.1.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.5-dev.
|
|
56
|
+
"@mikro-orm/core": "7.1.5-dev.23"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|