@mikro-orm/knex 6.0.0-dev.268 → 6.0.0-dev.269
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 +13 -5
- package/package.json +2 -2
package/AbstractSqlDriver.js
CHANGED
|
@@ -217,9 +217,9 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
217
217
|
}
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
|
-
|
|
220
|
+
let relationPojo = {};
|
|
221
221
|
meta2.props
|
|
222
|
-
.filter(prop => prop.persist === false && prop.fieldNames)
|
|
222
|
+
.filter(prop => !ref && prop.persist === false && prop.fieldNames)
|
|
223
223
|
.filter(prop => !prop.lazy || populate.some(p => p.field === prop.name || p.all))
|
|
224
224
|
.forEach(prop => {
|
|
225
225
|
/* istanbul ignore if */
|
|
@@ -231,7 +231,9 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
231
231
|
relationPojo[prop.name] = root[alias];
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
|
-
const props =
|
|
234
|
+
const props = ref
|
|
235
|
+
? meta2.getPrimaryProps()
|
|
236
|
+
: meta2.props.filter(prop => this.platform.shouldHaveColumn(prop, hint.children || []));
|
|
235
237
|
for (const prop1 of props) {
|
|
236
238
|
if (prop1.fieldNames.length > 1) { // composite keys
|
|
237
239
|
const fk = prop1.fieldNames.map(name => root[`${relationAlias}__${name}`]);
|
|
@@ -251,6 +253,10 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
251
253
|
for (const prop1 of props) {
|
|
252
254
|
prop1.fieldNames.map(name => delete root[`${relationAlias}__${name}`]);
|
|
253
255
|
}
|
|
256
|
+
if (ref) {
|
|
257
|
+
const tmp = Object.values(relationPojo);
|
|
258
|
+
relationPojo = meta2.compositePK ? tmp : tmp[0];
|
|
259
|
+
}
|
|
254
260
|
if ([core_1.ReferenceKind.MANY_TO_MANY, core_1.ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {
|
|
255
261
|
result[prop.name] ??= [];
|
|
256
262
|
result[prop.name].push(relationPojo);
|
|
@@ -764,8 +770,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
764
770
|
return false;
|
|
765
771
|
}
|
|
766
772
|
if (ref) {
|
|
767
|
-
|
|
768
|
-
return prop.kind === core_1.ReferenceKind.MANY_TO_MANY;
|
|
773
|
+
return [core_1.ReferenceKind.MANY_TO_MANY, core_1.ReferenceKind.ONE_TO_MANY].includes(prop.kind);
|
|
769
774
|
}
|
|
770
775
|
return ![core_1.ReferenceKind.SCALAR, core_1.ReferenceKind.EMBEDDED].includes(prop.kind);
|
|
771
776
|
});
|
|
@@ -847,6 +852,9 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
847
852
|
if (pivotRefJoin) {
|
|
848
853
|
fields.push(...prop.joinColumns.map(col => qb.helper.mapper(`${tableAlias}.${col}`, qb.type, undefined, `${tableAlias}__${col}`)), ...prop.inverseJoinColumns.map(col => qb.helper.mapper(`${tableAlias}.${col}`, qb.type, undefined, `${tableAlias}__${col}`)));
|
|
849
854
|
}
|
|
855
|
+
if (prop.kind === core_1.ReferenceKind.ONE_TO_MANY && ref) {
|
|
856
|
+
fields.push(...this.getFieldsForJoinedLoad(qb, meta2, prop.referencedColumnNames, hint.children, options, tableAlias, path));
|
|
857
|
+
}
|
|
850
858
|
const childExplicitFields = explicitFields?.filter(f => core_1.Utils.isPlainObject(f)).map(o => o[prop.name])[0] || [];
|
|
851
859
|
explicitFields?.forEach(f => {
|
|
852
860
|
if (typeof f === 'string' && f.startsWith(`${prop.name}.`)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.269",
|
|
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,6 +66,6 @@
|
|
|
66
66
|
"@mikro-orm/core": "^5.9.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.0.0-dev.
|
|
69
|
+
"@mikro-orm/core": "6.0.0-dev.269"
|
|
70
70
|
}
|
|
71
71
|
}
|