@mikro-orm/knex 6.2.1-dev.6 → 6.2.1-dev.8
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 +2 -2
- package/package.json +2 -2
- package/query/QueryBuilder.js +15 -0
package/AbstractSqlDriver.js
CHANGED
|
@@ -799,7 +799,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
799
799
|
}
|
|
800
800
|
const relationsToPopulate = populate.map(({ field }) => field.split(':')[0]);
|
|
801
801
|
const toPopulate = meta.relations
|
|
802
|
-
.filter(prop => prop.kind === core_1.ReferenceKind.ONE_TO_ONE && !prop.owner && !relationsToPopulate.includes(prop.name))
|
|
802
|
+
.filter(prop => prop.kind === core_1.ReferenceKind.ONE_TO_ONE && !prop.owner && !prop.lazy && !relationsToPopulate.includes(prop.name))
|
|
803
803
|
.filter(prop => fields.length === 0 || fields.some(f => prop.name === f || prop.name.startsWith(`${String(f)}.`)))
|
|
804
804
|
.map(prop => ({ field: `${prop.name}:ref`, strategy: prop.strategy }));
|
|
805
805
|
return [...populate, ...toPopulate];
|
|
@@ -1205,7 +1205,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
1205
1205
|
ret.unshift(...meta.primaryKeys.filter(pk => !options.fields.includes(pk)));
|
|
1206
1206
|
}
|
|
1207
1207
|
}
|
|
1208
|
-
else if (!core_1.Utils.isEmpty(options.exclude) || lazyProps.some(p => !p.formula)) {
|
|
1208
|
+
else if (!core_1.Utils.isEmpty(options.exclude) || lazyProps.some(p => !p.formula && (p.kind !== '1:1' || p.owner))) {
|
|
1209
1209
|
const props = meta.props.filter(prop => this.platform.shouldHaveColumn(prop, populate, options.exclude, false));
|
|
1210
1210
|
ret.push(...props.filter(p => !lazyProps.includes(p)).map(p => p.name));
|
|
1211
1211
|
addFormulas = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.2.1-dev.
|
|
3
|
+
"version": "6.2.1-dev.8",
|
|
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": "^6.2.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.2.1-dev.
|
|
69
|
+
"@mikro-orm/core": "6.2.1-dev.8"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/query/QueryBuilder.js
CHANGED
|
@@ -231,6 +231,21 @@ class QueryBuilder {
|
|
|
231
231
|
}
|
|
232
232
|
populate.push(...children);
|
|
233
233
|
}
|
|
234
|
+
for (const p of prop.targetMeta.getPrimaryProps()) {
|
|
235
|
+
fields.push(...this.driver.mapPropToFieldNames(this, p, alias));
|
|
236
|
+
}
|
|
237
|
+
if (explicitFields) {
|
|
238
|
+
for (const field of explicitFields) {
|
|
239
|
+
const [a, f] = this.helper.splitField(field);
|
|
240
|
+
const p = prop.targetMeta.properties[f];
|
|
241
|
+
if (p) {
|
|
242
|
+
fields.push(...this.driver.mapPropToFieldNames(this, p, alias));
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
fields.push(`${a}.${f} as ${a}__${f}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
234
249
|
prop.targetMeta.props
|
|
235
250
|
.filter(prop => explicitFields
|
|
236
251
|
? explicitFields.includes(prop.name) || explicitFields.includes(`${alias}.${prop.name}`) || prop.primary
|