@mikro-orm/knex 6.4.13-dev.14 → 6.4.13-dev.16
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 +7 -2
- 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.16",
|
|
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.16",
|
|
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
|
@@ -288,6 +288,12 @@ class QueryBuilder {
|
|
|
288
288
|
}
|
|
289
289
|
const cond = await em.applyFilters(join.prop.type, join.cond, filterOptions, 'read');
|
|
290
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) && !['$some', '$none', '$every'].includes(k)))) {
|
|
294
|
+
delete cond[key];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
291
297
|
if (core_1.Utils.hasObjectKeys(join.cond)) {
|
|
292
298
|
/* istanbul ignore next */
|
|
293
299
|
join.cond = { $and: [join.cond, cond] };
|
|
@@ -371,7 +377,7 @@ class QueryBuilder {
|
|
|
371
377
|
convertCustomTypes: false,
|
|
372
378
|
type: 'orderBy',
|
|
373
379
|
});
|
|
374
|
-
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' }));
|
|
375
381
|
});
|
|
376
382
|
return this;
|
|
377
383
|
}
|
|
@@ -1276,7 +1282,6 @@ class QueryBuilder {
|
|
|
1276
1282
|
}
|
|
1277
1283
|
hasToManyJoins() {
|
|
1278
1284
|
return Object.values(this._joins).some(join => {
|
|
1279
|
-
// console.log(join.prop.name, join.prop.kind, [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(join.prop.kind));
|
|
1280
1285
|
return [core_1.ReferenceKind.ONE_TO_MANY, core_1.ReferenceKind.MANY_TO_MANY].includes(join.prop.kind);
|
|
1281
1286
|
});
|
|
1282
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;
|