@mikro-orm/sql 7.2.12-dev.10 → 7.2.12-dev.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.2.12-dev.10",
3
+ "version": "7.2.12-dev.12",
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.11"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.12-dev.10"
56
+ "@mikro-orm/core": "7.2.12-dev.12"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -410,13 +410,19 @@ export class QueryBuilder {
410
410
  * @internal
411
411
  */
412
412
  async applyJoinedFilters(em, filterOptions) {
413
+ const joins = Object.values(this.#state.joins);
413
414
  for (const path of this.#state.autoJoinedPaths) {
414
415
  const join = this.getJoinForPath(path);
415
416
  if (join.type === JoinType.pivotJoin) {
416
417
  continue;
417
418
  }
418
- filterOptions = QueryHelper.mergePropertyFilters(join.prop.filters, filterOptions);
419
- let cond = await em.applyFilters(join.prop.targetMeta.class, join.cond, filterOptions, 'read');
419
+ // nested joins inherit the overrides of their ancestor relations
420
+ const chain = [join];
421
+ for (let parent; (parent = joins.find(j => j.alias === chain[0].ownerAlias));) {
422
+ chain.unshift(parent);
423
+ }
424
+ const joinFilters = chain.reduce((acc, j) => QueryHelper.mergePropertyFilters(j.prop.filters, acc), filterOptions);
425
+ let cond = await em.applyFilters(join.prop.targetMeta.class, join.cond, joinFilters, 'read');
420
426
  const criteriaNode = CriteriaNodeFactory.createNode(this.metadata, join.prop.targetMeta.class, cond);
421
427
  cond = criteriaNode.process(this, {
422
428
  matchPopulateJoins: true,