@mikro-orm/knex 6.4.13-dev.13 → 6.4.13-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/package.json +2 -2
- package/query/ObjectCriteriaNode.js +5 -3
- package/query/QueryBuilder.js +13 -6
- package/typings.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.4.13-dev.
|
|
3
|
+
"version": "6.4.13-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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@mikro-orm/core": "^6.4.12"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.4.13-dev.
|
|
69
|
+
"@mikro-orm/core": "6.4.13-dev.15",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
|
@@ -58,7 +58,7 @@ class ObjectCriteriaNode extends CriteriaNode_1.CriteriaNode {
|
|
|
58
58
|
}
|
|
59
59
|
return { $and };
|
|
60
60
|
}
|
|
61
|
-
alias = this.autoJoin(qb, ownerAlias);
|
|
61
|
+
alias = this.autoJoin(qb, ownerAlias, options);
|
|
62
62
|
}
|
|
63
63
|
return keys.reduce((o, field) => {
|
|
64
64
|
const childNode = this.payload[field];
|
|
@@ -196,7 +196,7 @@ class ObjectCriteriaNode extends CriteriaNode_1.CriteriaNode {
|
|
|
196
196
|
});
|
|
197
197
|
return !primaryKeys && !nestedAlias && !operatorKeys && !embeddable;
|
|
198
198
|
}
|
|
199
|
-
autoJoin(qb, alias) {
|
|
199
|
+
autoJoin(qb, alias, options) {
|
|
200
200
|
const nestedAlias = qb.getNextAlias(this.prop?.pivotTable ?? this.entityName);
|
|
201
201
|
const customExpression = core_1.RawQueryFragment.isKnownFragment(this.key);
|
|
202
202
|
const scalar = core_1.Utils.isPrimaryKey(this.payload) || this.payload instanceof RegExp || this.payload instanceof Date || customExpression;
|
|
@@ -214,7 +214,9 @@ class ObjectCriteriaNode extends CriteriaNode_1.CriteriaNode {
|
|
|
214
214
|
qb._fields = prev;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
if (!options || options.type !== 'orderBy') {
|
|
218
|
+
qb.scheduleFilterCheck(path);
|
|
219
|
+
}
|
|
218
220
|
return nestedAlias;
|
|
219
221
|
}
|
|
220
222
|
isPrefixed(field) {
|
package/query/QueryBuilder.js
CHANGED
|
@@ -250,9 +250,12 @@ class QueryBuilder {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
prop.targetMeta.props
|
|
253
|
-
.filter(prop =>
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
.filter(prop => {
|
|
254
|
+
if (!explicitFields) {
|
|
255
|
+
return this.platform.shouldHaveColumn(prop, populate);
|
|
256
|
+
}
|
|
257
|
+
return prop.primary && !explicitFields.includes(prop.name) && !explicitFields.includes(`${alias}.${prop.name}`);
|
|
258
|
+
})
|
|
256
259
|
.forEach(prop => fields.push(...this.driver.mapPropToFieldNames(this, prop, alias)));
|
|
257
260
|
return fields;
|
|
258
261
|
}
|
|
@@ -285,6 +288,12 @@ class QueryBuilder {
|
|
|
285
288
|
}
|
|
286
289
|
const cond = await em.applyFilters(join.prop.type, join.cond, filterOptions, 'read');
|
|
287
290
|
if (core_1.Utils.hasObjectKeys(cond)) {
|
|
291
|
+
// remove nested filters, we only care about scalars here, nesting would require another join branch
|
|
292
|
+
for (const key of Object.keys(cond)) {
|
|
293
|
+
if (core_1.Utils.isPlainObject(cond[key]) && Object.keys(cond[key]).every(k => !core_1.Utils.isOperator(k))) {
|
|
294
|
+
delete cond[key];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
288
297
|
if (core_1.Utils.hasObjectKeys(join.cond)) {
|
|
289
298
|
/* istanbul ignore next */
|
|
290
299
|
join.cond = { $and: [join.cond, cond] };
|
|
@@ -368,7 +377,7 @@ class QueryBuilder {
|
|
|
368
377
|
convertCustomTypes: false,
|
|
369
378
|
type: 'orderBy',
|
|
370
379
|
});
|
|
371
|
-
this._orderBy.push(CriteriaNodeFactory_1.CriteriaNodeFactory.createNode(this.metadata, this.mainAlias.entityName, processed).process(this, { matchPopulateJoins: true }));
|
|
380
|
+
this._orderBy.push(CriteriaNodeFactory_1.CriteriaNodeFactory.createNode(this.metadata, this.mainAlias.entityName, processed).process(this, { matchPopulateJoins: true, type: 'orderBy' }));
|
|
372
381
|
});
|
|
373
382
|
return this;
|
|
374
383
|
}
|
|
@@ -1272,9 +1281,7 @@ class QueryBuilder {
|
|
|
1272
1281
|
}
|
|
1273
1282
|
}
|
|
1274
1283
|
hasToManyJoins() {
|
|
1275
|
-
// console.log(this._joins);
|
|
1276
1284
|
return Object.values(this._joins).some(join => {
|
|
1277
|
-
// console.log(join.prop.name, join.prop.kind, [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(join.prop.kind));
|
|
1278
1285
|
return [core_1.ReferenceKind.ONE_TO_MANY, core_1.ReferenceKind.MANY_TO_MANY].includes(join.prop.kind);
|
|
1279
1286
|
});
|
|
1280
1287
|
}
|
package/typings.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ export interface ICriteriaNodeProcessOptions {
|
|
|
170
170
|
matchPopulateJoins?: boolean;
|
|
171
171
|
ignoreBranching?: boolean;
|
|
172
172
|
preferNoBranch?: boolean;
|
|
173
|
+
type?: 'orderBy';
|
|
173
174
|
}
|
|
174
175
|
export interface ICriteriaNode<T extends object> {
|
|
175
176
|
readonly entityName: string;
|