@mikro-orm/sql 7.2.1-dev.13 → 7.2.1-dev.15
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 +10 -3
- package/package.json +2 -2
package/AbstractSqlDriver.js
CHANGED
|
@@ -352,6 +352,13 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
352
352
|
if (!prop) {
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
+
// A condition can join the target without selecting its columns. Keep the FK
|
|
356
|
+
// already mapped from the root row for reference-only owning to-one relations.
|
|
357
|
+
if (ref &&
|
|
358
|
+
!hint.filter &&
|
|
359
|
+
(prop.kind === ReferenceKind.MANY_TO_ONE || (prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner))) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
355
362
|
// Polymorphic to-one: iterate targets, find the matching one, build entity from its columns.
|
|
356
363
|
// Skip :ref hints — no JOINs were created, so the FK reference is already set by the result mapper.
|
|
357
364
|
if (prop.polymorphic &&
|
|
@@ -400,7 +407,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
400
407
|
}
|
|
401
408
|
return;
|
|
402
409
|
}
|
|
403
|
-
const pivotRefJoin = prop.kind === ReferenceKind.MANY_TO_MANY && ref;
|
|
410
|
+
const pivotRefJoin = prop.kind === ReferenceKind.MANY_TO_MANY && ref && !hint.filter;
|
|
404
411
|
const meta2 = prop.targetMeta;
|
|
405
412
|
let path = parentJoinPath ? `${parentJoinPath}.${prop.name}` : `${meta.name}.${prop.name}`;
|
|
406
413
|
if (!parentJoinPath) {
|
|
@@ -1863,7 +1870,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
1863
1870
|
continue;
|
|
1864
1871
|
}
|
|
1865
1872
|
const meta2 = prop.targetMeta;
|
|
1866
|
-
const pivotRefJoin = prop.kind === ReferenceKind.MANY_TO_MANY && ref;
|
|
1873
|
+
const pivotRefJoin = prop.kind === ReferenceKind.MANY_TO_MANY && ref && !hint.filter;
|
|
1867
1874
|
const tableAlias = qb.getNextAlias(prop.name);
|
|
1868
1875
|
const field = `${options.parentTableAlias}.${prop.name}`;
|
|
1869
1876
|
let path = options.parentJoinPath ? `${options.parentJoinPath}.${prop.name}` : `${meta.name}.${prop.name}`;
|
|
@@ -1875,7 +1882,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
1875
1882
|
? JoinType.pivotJoin
|
|
1876
1883
|
: hint.joinType
|
|
1877
1884
|
? hint.joinType
|
|
1878
|
-
: (hint.filter && !prop.nullable) || mandatoryToOneProperty
|
|
1885
|
+
: (hint.filter && !prop.nullable && prop.kind !== ReferenceKind.MANY_TO_MANY) || mandatoryToOneProperty
|
|
1879
1886
|
? JoinType.innerJoin
|
|
1880
1887
|
: JoinType.leftJoin;
|
|
1881
1888
|
const schema = prop.targetMeta.schema === '*' ? (options?.schema ?? this.config.get('schema')) : prop.targetMeta.schema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.1-dev.
|
|
3
|
+
"version": "7.2.1-dev.15",
|
|
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.2.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.1-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.1-dev.15"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|