@mikro-orm/knex 6.5.2-dev.0 → 6.5.2-dev.2

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/knex",
3
- "version": "6.5.2-dev.0",
3
+ "version": "6.5.2-dev.2",
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.5.1"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.5.2-dev.0",
69
+ "@mikro-orm/core": "6.5.2-dev.2",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -1294,17 +1294,27 @@ class QueryBuilder {
1294
1294
  return;
1295
1295
  }
1296
1296
  const joins = Object.values(this._joins);
1297
+ const lookupParentGroup = (j) => {
1298
+ return j.nested ?? (j.parent ? lookupParentGroup(j.parent) : undefined);
1299
+ };
1297
1300
  for (const join of joins) {
1298
1301
  if (join.type === enums_1.JoinType.innerJoin) {
1299
- const parentJoin = joins.find(j => j.alias === join.ownerAlias);
1302
+ join.parent = joins.find(j => j.alias === join.ownerAlias);
1300
1303
  // https://stackoverflow.com/a/56815807/3665878
1301
- if (parentJoin?.type === enums_1.JoinType.leftJoin || parentJoin?.type === enums_1.JoinType.nestedLeftJoin) {
1302
- const nested = (parentJoin.nested ??= new Set());
1304
+ if (join.parent?.type === enums_1.JoinType.leftJoin || join.parent?.type === enums_1.JoinType.nestedLeftJoin) {
1305
+ const nested = ((join.parent).nested ??= new Set());
1303
1306
  join.type = join.type === enums_1.JoinType.innerJoin
1304
1307
  ? enums_1.JoinType.nestedInnerJoin
1305
1308
  : enums_1.JoinType.nestedLeftJoin;
1306
1309
  nested.add(join);
1307
1310
  }
1311
+ else if (join.parent?.type === enums_1.JoinType.nestedInnerJoin) {
1312
+ const group = lookupParentGroup(join.parent);
1313
+ join.type = join.type === enums_1.JoinType.innerJoin
1314
+ ? enums_1.JoinType.nestedInnerJoin
1315
+ : enums_1.JoinType.nestedLeftJoin;
1316
+ group?.add(join);
1317
+ }
1308
1318
  }
1309
1319
  }
1310
1320
  }
package/typings.d.ts CHANGED
@@ -28,6 +28,7 @@ export interface JoinOptions {
28
28
  cond_?: Dictionary;
29
29
  subquery?: string;
30
30
  nested?: Set<JoinOptions>;
31
+ parent?: JoinOptions;
31
32
  }
32
33
  export interface Column {
33
34
  name: string;