linkgress-orm 0.3.2 → 0.4.0

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.
Files changed (33) hide show
  1. package/dist/entity/entity-base.d.ts +2 -2
  2. package/dist/entity/entity-base.d.ts.map +1 -1
  3. package/dist/entity/entity-builder.d.ts +9 -8
  4. package/dist/entity/entity-builder.d.ts.map +1 -1
  5. package/dist/entity/entity-builder.js +49 -17
  6. package/dist/entity/entity-builder.js.map +1 -1
  7. package/dist/entity/model-config.d.ts.map +1 -1
  8. package/dist/entity/model-config.js +41 -22
  9. package/dist/entity/model-config.js.map +1 -1
  10. package/dist/query/conditions.d.ts.map +1 -1
  11. package/dist/query/conditions.js +10 -6
  12. package/dist/query/conditions.js.map +1 -1
  13. package/dist/query/grouped-query.d.ts.map +1 -1
  14. package/dist/query/grouped-query.js +2 -1
  15. package/dist/query/grouped-query.js.map +1 -1
  16. package/dist/query/join-utils.d.ts +17 -0
  17. package/dist/query/join-utils.d.ts.map +1 -0
  18. package/dist/query/join-utils.js +29 -0
  19. package/dist/query/join-utils.js.map +1 -0
  20. package/dist/query/query-builder.d.ts.map +1 -1
  21. package/dist/query/query-builder.js +19 -8
  22. package/dist/query/query-builder.js.map +1 -1
  23. package/dist/query/strategies/cte-collection-strategy.d.ts.map +1 -1
  24. package/dist/query/strategies/cte-collection-strategy.js +2 -1
  25. package/dist/query/strategies/cte-collection-strategy.js.map +1 -1
  26. package/dist/query/strategies/lateral-collection-strategy.d.ts.map +1 -1
  27. package/dist/query/strategies/lateral-collection-strategy.js +3 -2
  28. package/dist/query/strategies/lateral-collection-strategy.js.map +1 -1
  29. package/dist/schema/navigation.d.ts +4 -4
  30. package/dist/schema/navigation.d.ts.map +1 -1
  31. package/dist/schema/navigation.js +10 -10
  32. package/dist/schema/navigation.js.map +1 -1
  33. package/package.json +1 -1
@@ -15,6 +15,7 @@ const cte_builder_1 = require("./cte-builder");
15
15
  const collection_strategy_factory_1 = require("./collection-strategy.factory");
16
16
  const union_builder_1 = require("./union-builder");
17
17
  const future_query_1 = require("./future-query");
18
+ const join_utils_1 = require("./join-utils");
18
19
  /**
19
20
  * Field type categories for optimized result transformation
20
21
  * const enum is inlined at compile time for zero runtime overhead
@@ -1923,7 +1924,7 @@ class SelectQueryBuilder {
1923
1924
  for (let i = 0; i < join.foreignKeys.length; i++) {
1924
1925
  const fk = join.foreignKeys[i];
1925
1926
  const match = join.matches[i];
1926
- joinConditions.push(`"${sourceTable}"."${fk}" = "${join.alias}"."${match}"`);
1927
+ joinConditions.push(`${(0, join_utils_1.formatJoinValue)(sourceTable, fk)} = ${(0, join_utils_1.formatJoinValue)(join.alias, match)}`);
1927
1928
  }
1928
1929
  }
1929
1930
  // Combine join conditions with the original WHERE clause
@@ -2062,7 +2063,7 @@ class SelectQueryBuilder {
2062
2063
  for (let i = 0; i < join.foreignKeys.length; i++) {
2063
2064
  const fk = join.foreignKeys[i];
2064
2065
  const match = join.matches[i];
2065
- joinConditions.push(`"${sourceTable}"."${fk}" = "${join.alias}"."${match}"`);
2066
+ joinConditions.push(`${(0, join_utils_1.formatJoinValue)(sourceTable, fk)} = ${(0, join_utils_1.formatJoinValue)(join.alias, match)}`);
2066
2067
  }
2067
2068
  }
2068
2069
  // Combine join conditions with the original WHERE clause
@@ -2399,6 +2400,8 @@ class SelectQueryBuilder {
2399
2400
  // Only add FK to mainTableColumns if the join source is the main table
2400
2401
  if (join.sourceAlias === this.schema.name || !join.sourceAlias) {
2401
2402
  for (const fk of join.foreignKeys) {
2403
+ if ((0, join_utils_1.isLiteralKeyPart)(fk))
2404
+ continue; // Skip literal values
2402
2405
  const fkDbCol = getFkDbColumnName(this.schema, fk);
2403
2406
  mainTableColumns.add(fkDbCol);
2404
2407
  }
@@ -2430,17 +2433,25 @@ class SelectQueryBuilder {
2430
2433
  for (let i = 0; i < join.foreignKeys.length; i++) {
2431
2434
  const fk = join.foreignKeys[i];
2432
2435
  const match = join.matches[i] || 'id';
2433
- if (join.sourceAlias === this.schema.name || !join.sourceAlias) {
2436
+ if ((0, join_utils_1.isLiteralKeyPart)(fk) || (0, join_utils_1.isLiteralKeyPart)(match)) {
2437
+ // Literal key parts don't need column name resolution
2438
+ const fkSide = (0, join_utils_1.isLiteralKeyPart)(fk)
2439
+ ? (0, join_utils_1.formatJoinValue)('', fk)
2440
+ : `"${join.sourceAlias === this.schema.name || !join.sourceAlias ? '__mutation__' : join.sourceAlias}"."${getFkDbColumnName(this.schema, fk)}"`;
2441
+ const matchSide = (0, join_utils_1.formatJoinValue)(join.alias, match);
2442
+ joinConditions.push(`${fkSide} = ${matchSide}`);
2443
+ }
2444
+ else if (join.sourceAlias === this.schema.name || !join.sourceAlias) {
2434
2445
  // FK is on main table - look up db column name from main schema
2435
2446
  const fkDbCol = getFkDbColumnName(this.schema, fk);
2436
- joinConditions.push(`"__mutation__"."${fkDbCol}" = "${join.alias}"."${match}"`);
2447
+ joinConditions.push(`"__mutation__"."${fkDbCol}" = ${(0, join_utils_1.formatJoinValue)(join.alias, match)}`);
2437
2448
  }
2438
2449
  else {
2439
2450
  // FK is on an intermediate joined table - look up from its schema
2440
2451
  const sourceTableName = aliasToSourceTable.get(join.sourceAlias);
2441
2452
  const sourceSchema = sourceTableName && this.schemaRegistry ? this.schemaRegistry.get(sourceTableName) : undefined;
2442
2453
  const fkDbCol = sourceSchema ? getFkDbColumnName(sourceSchema, fk) : fk;
2443
- joinConditions.push(`"${join.sourceAlias}"."${fkDbCol}" = "${join.alias}"."${match}"`);
2454
+ joinConditions.push(`"${join.sourceAlias}"."${fkDbCol}" = ${(0, join_utils_1.formatJoinValue)(join.alias, match)}`);
2444
2455
  }
2445
2456
  }
2446
2457
  const joinType = join.isMandatory ? 'INNER JOIN' : 'LEFT JOIN';
@@ -3559,7 +3570,7 @@ ${joinClauses.join('\n')}`;
3559
3570
  for (let i = 0; i < join.foreignKeys.length; i++) {
3560
3571
  const fk = join.foreignKeys[i];
3561
3572
  const match = join.matches[i];
3562
- onConditions.push(`"${sourceTable}"."${fk}" = "${join.alias}"."${match}"`);
3573
+ onConditions.push(`${(0, join_utils_1.formatJoinValue)(sourceTable, fk)} = ${(0, join_utils_1.formatJoinValue)(join.alias, match)}`);
3563
3574
  }
3564
3575
  // Use schema-qualified table name if schema is specified
3565
3576
  const joinTableName = this.getQualifiedTableName(join.targetTable, join.targetSchema);
@@ -3794,7 +3805,7 @@ ${joinClauses.join('\n')}`;
3794
3805
  for (let i = 0; i < join.foreignKeys.length; i++) {
3795
3806
  const fk = join.foreignKeys[i];
3796
3807
  const match = join.matches[i];
3797
- onConditions.push(`"${sourceTable}"."${fk}" = "${join.alias}"."${match}"`);
3808
+ onConditions.push(`${(0, join_utils_1.formatJoinValue)(sourceTable, fk)} = ${(0, join_utils_1.formatJoinValue)(join.alias, match)}`);
3798
3809
  }
3799
3810
  const joinTableName = this.getQualifiedTableName(join.targetTable, join.targetSchema);
3800
3811
  fromClause += `\n${joinType} ${joinTableName} AS "${join.alias}" ON ${onConditions.join(' AND ')}`;
@@ -4442,7 +4453,7 @@ ${joinClauses.join('\n')}`;
4442
4453
  for (let i = 0; i < join.foreignKeys.length; i++) {
4443
4454
  const fk = join.foreignKeys[i];
4444
4455
  const match = join.matches[i];
4445
- onConditions.push(`"${sourceTable}"."${fk}" = "${join.alias}"."${match}"`);
4456
+ onConditions.push(`${(0, join_utils_1.formatJoinValue)(sourceTable, fk)} = ${(0, join_utils_1.formatJoinValue)(join.alias, match)}`);
4446
4457
  }
4447
4458
  // Use schema-qualified table name if schema is specified
4448
4459
  const joinTableName = this.getQualifiedTableName(join.targetTable, join.targetSchema);