linkgress-orm 0.2.3 → 0.2.5
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/dist/entity/db-context.d.ts +32 -0
- package/dist/entity/db-context.d.ts.map +1 -1
- package/dist/entity/db-context.js +258 -1
- package/dist/entity/db-context.js.map +1 -1
- package/dist/query/conditions.d.ts +12 -0
- package/dist/query/conditions.d.ts.map +1 -1
- package/dist/query/conditions.js +26 -0
- package/dist/query/conditions.js.map +1 -1
- package/dist/query/query-builder.d.ts +33 -3
- package/dist/query/query-builder.d.ts.map +1 -1
- package/dist/query/query-builder.js +353 -21
- package/dist/query/query-builder.js.map +1 -1
- package/dist/query/strategies/cte-collection-strategy.d.ts.map +1 -1
- package/dist/query/strategies/cte-collection-strategy.js +67 -23
- package/dist/query/strategies/cte-collection-strategy.js.map +1 -1
- package/dist/query/strategies/lateral-collection-strategy.d.ts +9 -0
- package/dist/query/strategies/lateral-collection-strategy.d.ts.map +1 -1
- package/dist/query/strategies/lateral-collection-strategy.js +187 -70
- package/dist/query/strategies/lateral-collection-strategy.js.map +1 -1
- package/dist/query/strategies/temptable-collection-strategy.d.ts +5 -0
- package/dist/query/strategies/temptable-collection-strategy.d.ts.map +1 -1
- package/dist/query/strategies/temptable-collection-strategy.js +27 -10
- package/dist/query/strategies/temptable-collection-strategy.js.map +1 -1
- package/package.json +1 -1
|
@@ -125,14 +125,25 @@ class LateralCollectionStrategy {
|
|
|
125
125
|
* is often more efficient than: LEFT JOIN LATERAL (...) ON true
|
|
126
126
|
*/
|
|
127
127
|
buildCorrelatedSubqueryAggregation(config, lateralAlias, context) {
|
|
128
|
-
const { arrayField, targetTable, foreignKey, sourceTable, whereClause, isDistinct,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
const { arrayField, targetTable, foreignKey, sourceTable, whereClause, isDistinct, selectedFields, aggregationType, aggregateField, defaultValue, relationName, selectorNavigationJoins } = config;
|
|
129
|
+
// Use a unique table alias to avoid conflicts with outer query tables
|
|
130
|
+
const innerTableAlias = `${lateralAlias}_${relationName}`;
|
|
131
|
+
// For correlated subqueries, we only need selector navigation joins (joins within the selector),
|
|
132
|
+
// NOT the path navigation joins. Path navigation joins are part of the outer query's joins.
|
|
133
|
+
const hasNavigationJoins = selectorNavigationJoins && selectorNavigationJoins.length > 0;
|
|
134
|
+
// Helper to rewrite expressions that reference the collection's table to use inner alias
|
|
135
|
+
const rewriteTableReference = (expression) => {
|
|
136
|
+
// Replace the special marker alias `"__collection_tableName__".` with `"innerTableAlias".`
|
|
137
|
+
const markerPattern = new RegExp(`"__collection_${targetTable}__"\\.`, 'g');
|
|
138
|
+
return expression.replace(markerPattern, `"${innerTableAlias}".`);
|
|
139
|
+
};
|
|
140
|
+
// Build navigation JOINs for multi-level navigation (selector joins only)
|
|
141
|
+
const navJoinsSQL = this.buildNavigationJoinsWithAlias(selectorNavigationJoins, innerTableAlias, targetTable, context);
|
|
132
142
|
// Build WHERE clause with correlation to parent
|
|
133
|
-
let whereSQL = `"${
|
|
143
|
+
let whereSQL = `"${innerTableAlias}"."${foreignKey}" = "${sourceTable}"."id"`;
|
|
134
144
|
if (whereClause) {
|
|
135
|
-
|
|
145
|
+
const rewrittenWhereClause = rewriteTableReference(whereClause);
|
|
146
|
+
whereSQL += ` AND ${rewrittenWhereClause}`;
|
|
136
147
|
}
|
|
137
148
|
let subquerySQL;
|
|
138
149
|
if (aggregationType === 'array') {
|
|
@@ -140,14 +151,11 @@ class LateralCollectionStrategy {
|
|
|
140
151
|
throw new Error('arrayField is required for array aggregation');
|
|
141
152
|
}
|
|
142
153
|
// Get the actual field expression from selectedFields (if available)
|
|
143
|
-
let fieldExpression = `"${arrayField}"`;
|
|
154
|
+
let fieldExpression = `"${innerTableAlias}"."${arrayField}"`;
|
|
144
155
|
if (selectedFields && selectedFields.length > 0) {
|
|
145
156
|
const firstField = selectedFields[0];
|
|
146
157
|
if (firstField.expression && firstField.expression !== `"${arrayField}"`) {
|
|
147
|
-
fieldExpression = firstField.expression;
|
|
148
|
-
}
|
|
149
|
-
else if (hasNavigationJoins) {
|
|
150
|
-
fieldExpression = `"${targetTable}"."${arrayField}"`;
|
|
158
|
+
fieldExpression = rewriteTableReference(firstField.expression);
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
// Build correlated subquery for array aggregation
|
|
@@ -157,13 +165,13 @@ class LateralCollectionStrategy {
|
|
|
157
165
|
if (isDistinct) {
|
|
158
166
|
subquerySQL = `(SELECT COALESCE(array_agg("${arrayField}"), ${defaultValue})
|
|
159
167
|
FROM (SELECT DISTINCT ${fieldExpression} as "${arrayField}"
|
|
160
|
-
FROM "${targetTable}"
|
|
168
|
+
FROM "${targetTable}" "${innerTableAlias}"
|
|
161
169
|
${navJoinsSQL}
|
|
162
170
|
WHERE ${whereSQL}) "sq")`;
|
|
163
171
|
}
|
|
164
172
|
else {
|
|
165
173
|
subquerySQL = `(SELECT COALESCE(array_agg(${fieldExpression}), ${defaultValue})
|
|
166
|
-
FROM "${targetTable}"
|
|
174
|
+
FROM "${targetTable}" "${innerTableAlias}"
|
|
167
175
|
${navJoinsSQL}
|
|
168
176
|
WHERE ${whereSQL})`;
|
|
169
177
|
}
|
|
@@ -181,14 +189,14 @@ WHERE ${whereSQL})`;
|
|
|
181
189
|
if (!aggregateField) {
|
|
182
190
|
throw new Error(`${aggregationType.toUpperCase()} requires an aggregate field`);
|
|
183
191
|
}
|
|
184
|
-
aggregateExpression = `${aggregationType.toUpperCase()}("${aggregateField}")`;
|
|
192
|
+
aggregateExpression = `${aggregationType.toUpperCase()}("${innerTableAlias}"."${aggregateField}")`;
|
|
185
193
|
break;
|
|
186
194
|
default:
|
|
187
195
|
throw new Error(`Unknown aggregation type: ${aggregationType}`);
|
|
188
196
|
}
|
|
189
197
|
// Build correlated subquery for scalar aggregation
|
|
190
198
|
subquerySQL = `(SELECT COALESCE(${aggregateExpression}, ${defaultValue})
|
|
191
|
-
FROM "${targetTable}"
|
|
199
|
+
FROM "${targetTable}" "${innerTableAlias}"
|
|
192
200
|
${navJoinsSQL}
|
|
193
201
|
WHERE ${whereSQL})`;
|
|
194
202
|
}
|
|
@@ -245,11 +253,68 @@ WHERE ${whereSQL})`;
|
|
|
245
253
|
}
|
|
246
254
|
return joinClauses.join('\n ');
|
|
247
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Build navigation JOINs SQL with inner table alias mapping
|
|
258
|
+
* Similar to buildNavigationJoins but uses innerTableAlias for the collection's own table
|
|
259
|
+
* @param navigationJoins - The navigation joins to build
|
|
260
|
+
* @param innerTableAlias - The alias used for the collection's target table (e.g., "lateral_0_posts")
|
|
261
|
+
* @param targetTable - Optional: the original target table name (e.g., "posts") to map to innerTableAlias
|
|
262
|
+
* @param context - Optional: QueryContext containing lateralTableAliasMap for nested lateral references
|
|
263
|
+
*/
|
|
264
|
+
buildNavigationJoinsWithAlias(navigationJoins, innerTableAlias, targetTable, context) {
|
|
265
|
+
if (!navigationJoins || navigationJoins.length === 0) {
|
|
266
|
+
return '';
|
|
267
|
+
}
|
|
268
|
+
// Extract the relation name from innerTableAlias (e.g., "lateral_0_posts" -> "posts")
|
|
269
|
+
// This is needed to know which source aliases should be remapped
|
|
270
|
+
const parts = innerTableAlias.split('_');
|
|
271
|
+
const relationName = parts.length >= 3 ? parts.slice(2).join('_') : innerTableAlias;
|
|
272
|
+
// Get the lateral table alias map from context (for nested lateral references)
|
|
273
|
+
// This is used when a nested collection's selector navigation references a parent collection's table
|
|
274
|
+
const lateralAliasMap = context?.lateralTableAliasMap;
|
|
275
|
+
const joinClauses = [];
|
|
276
|
+
for (const join of navigationJoins) {
|
|
277
|
+
const joinType = join.isMandatory ? 'INNER JOIN' : 'LEFT JOIN';
|
|
278
|
+
const qualifiedTable = join.targetSchema
|
|
279
|
+
? `"${join.targetSchema}"."${join.targetTable}"`
|
|
280
|
+
: `"${join.targetTable}"`;
|
|
281
|
+
// Build the ON clause
|
|
282
|
+
// foreignKeys are the columns in the source table
|
|
283
|
+
// matches are the columns in the target table (usually primary keys)
|
|
284
|
+
const onConditions = [];
|
|
285
|
+
for (let i = 0; i < join.foreignKeys.length; i++) {
|
|
286
|
+
const fk = join.foreignKeys[i];
|
|
287
|
+
const pk = join.matches[i] || 'id';
|
|
288
|
+
// Use innerTableAlias if the source alias matches the collection's target table or relation name
|
|
289
|
+
// This handles the case where we've aliased the main FROM table
|
|
290
|
+
let sourceAlias = join.sourceAlias;
|
|
291
|
+
if (targetTable && sourceAlias === targetTable) {
|
|
292
|
+
// This join's source is the current collection's table - use inner alias
|
|
293
|
+
sourceAlias = innerTableAlias;
|
|
294
|
+
}
|
|
295
|
+
else if (sourceAlias === relationName) {
|
|
296
|
+
sourceAlias = innerTableAlias;
|
|
297
|
+
}
|
|
298
|
+
else if (lateralAliasMap && lateralAliasMap.has(sourceAlias)) {
|
|
299
|
+
// For nested collections, if the source references a parent collection's table,
|
|
300
|
+
// use the parent's aliased name from the map
|
|
301
|
+
sourceAlias = lateralAliasMap.get(sourceAlias);
|
|
302
|
+
}
|
|
303
|
+
onConditions.push(`"${sourceAlias}"."${fk}" = "${join.alias}"."${pk}"`);
|
|
304
|
+
}
|
|
305
|
+
joinClauses.push(`${joinType} ${qualifiedTable} "${join.alias}" ON ${onConditions.join(' AND ')}`);
|
|
306
|
+
}
|
|
307
|
+
return joinClauses.join('\n ');
|
|
308
|
+
}
|
|
248
309
|
/**
|
|
249
310
|
* Build JSONB aggregation using LATERAL
|
|
250
311
|
*/
|
|
251
312
|
buildJsonbAggregation(config, lateralAlias, context) {
|
|
252
|
-
const { selectedFields, targetTable, foreignKey, sourceTable, whereClause, orderByClause, limitValue, offsetValue, isDistinct, navigationJoins } = config;
|
|
313
|
+
const { selectedFields, targetTable, foreignKey, sourceTable, whereClause, orderByClause, limitValue, offsetValue, isDistinct, navigationJoins, relationName } = config;
|
|
314
|
+
// Use a unique table alias to avoid conflicts with outer query tables
|
|
315
|
+
// This is important when the collection targets the same table as the outer query
|
|
316
|
+
// (e.g., post.user.posts where both outer and inner are "posts" table)
|
|
317
|
+
const innerTableAlias = `${lateralAlias}_${relationName}`;
|
|
253
318
|
// Helper to collect all leaf fields from a potentially nested structure
|
|
254
319
|
const collectLeafFields = (fields, prefix = '') => {
|
|
255
320
|
const result = [];
|
|
@@ -282,38 +347,59 @@ WHERE ${whereSQL})`;
|
|
|
282
347
|
// Collect all leaf fields for the SELECT clause
|
|
283
348
|
const leafFields = collectLeafFields(selectedFields);
|
|
284
349
|
// When there are navigation joins, we need to qualify unqualified field expressions
|
|
285
|
-
// with the
|
|
350
|
+
// with the inner table alias to avoid ambiguous column references
|
|
286
351
|
const hasNavigationJoins = navigationJoins && navigationJoins.length > 0;
|
|
352
|
+
// Helper to rewrite expressions that reference the collection's table to use inner alias
|
|
353
|
+
const rewriteTableReference = (expression) => {
|
|
354
|
+
// Replace the special marker alias `"__collection_tableName__".` with `"innerTableAlias".`
|
|
355
|
+
// This marker is set in CollectionQueryBuilder.createMockItem() to distinguish
|
|
356
|
+
// collection references from outer table references when both target the same table
|
|
357
|
+
const markerPattern = new RegExp(`"__collection_${targetTable}__"\\.`, 'g');
|
|
358
|
+
return expression.replace(markerPattern, `"${innerTableAlias}".`);
|
|
359
|
+
};
|
|
287
360
|
// Build the subquery SELECT fields (no foreign key needed since we correlate with parent)
|
|
288
361
|
const allSelectFields = leafFields.map(f => {
|
|
289
|
-
// If expression is just a quoted column name (e.g., `"id"`), qualify it with
|
|
290
|
-
// But if it's already qualified (e.g., `"user"."username"`),
|
|
362
|
+
// If expression is just a quoted column name (e.g., `"id"`), qualify it with inner table alias
|
|
363
|
+
// But if it's already qualified (e.g., `"user"."username"`), rewrite if it references target table
|
|
291
364
|
const isSimpleColumn = /^"[^".]+"$/.test(f.expression);
|
|
292
|
-
if (isSimpleColumn
|
|
293
|
-
//
|
|
365
|
+
if (isSimpleColumn) {
|
|
366
|
+
// Unqualified column - qualify with inner table alias
|
|
294
367
|
const columnName = f.expression.slice(1, -1); // Remove quotes
|
|
295
|
-
return `"${
|
|
368
|
+
return `"${innerTableAlias}"."${columnName}" as "${f.alias}"`;
|
|
296
369
|
}
|
|
297
|
-
|
|
298
|
-
|
|
370
|
+
// Already qualified - rewrite target table references
|
|
371
|
+
const rewritten = rewriteTableReference(f.expression);
|
|
372
|
+
if (rewritten !== `"${f.alias}"`) {
|
|
373
|
+
return `${rewritten} as "${f.alias}"`;
|
|
299
374
|
}
|
|
300
|
-
return
|
|
375
|
+
return rewritten;
|
|
301
376
|
});
|
|
302
377
|
// Build the JSONB fields for json_build_object
|
|
303
378
|
const jsonbObjectExpr = buildJsonbObject(selectedFields);
|
|
304
379
|
// Build navigation JOINs for multi-level navigation
|
|
305
|
-
|
|
380
|
+
// Pass innerTableAlias so navigation joins can reference it properly
|
|
381
|
+
const navJoinsSQL = this.buildNavigationJoinsWithAlias(navigationJoins, innerTableAlias, targetTable, context);
|
|
306
382
|
// Collect nested CTE/LATERAL joins (for collections within collections)
|
|
307
383
|
const nestedCteJoins = this.collectNestedCteJoins(selectedFields);
|
|
308
384
|
const nestedCteJoinsSQL = nestedCteJoins.length > 0 ? nestedCteJoins.join('\n ') : '';
|
|
385
|
+
// For nested collections, the source table may be aliased in a parent LATERAL
|
|
386
|
+
// Check the lateralTableAliasMap to get the correct alias
|
|
387
|
+
const effectiveSourceTable = context.lateralTableAliasMap?.get(sourceTable) || sourceTable;
|
|
309
388
|
// Build WHERE clause - LATERAL correlates with parent via foreign key
|
|
310
|
-
// The correlation is:
|
|
311
|
-
|
|
389
|
+
// The correlation is: innerAlias.foreignKey = source.id
|
|
390
|
+
// Use the innerTableAlias for the collection's own table
|
|
391
|
+
let whereSQL = `WHERE "${innerTableAlias}"."${foreignKey}" = "${effectiveSourceTable}"."id"`;
|
|
312
392
|
if (whereClause) {
|
|
313
|
-
|
|
393
|
+
// Rewrite the user's WHERE clause to use inner alias for the collection's table
|
|
394
|
+
const rewrittenWhereClause = rewriteTableReference(whereClause);
|
|
395
|
+
whereSQL += ` AND ${rewrittenWhereClause}`;
|
|
396
|
+
}
|
|
397
|
+
// Build ORDER BY clause - also rewrite table references
|
|
398
|
+
let orderBySQL = '';
|
|
399
|
+
if (orderByClause) {
|
|
400
|
+
const rewrittenOrderBy = rewriteTableReference(orderByClause);
|
|
401
|
+
orderBySQL = `ORDER BY ${rewrittenOrderBy}`;
|
|
314
402
|
}
|
|
315
|
-
// Build ORDER BY clause
|
|
316
|
-
const orderBySQL = orderByClause ? `ORDER BY ${orderByClause}` : '';
|
|
317
403
|
// Build LIMIT/OFFSET
|
|
318
404
|
let limitOffsetClause = '';
|
|
319
405
|
if (limitValue !== undefined) {
|
|
@@ -334,7 +420,7 @@ SELECT json_agg(
|
|
|
334
420
|
) as data
|
|
335
421
|
FROM (
|
|
336
422
|
SELECT ${distinctClause}${allSelectFields.join(', ')}
|
|
337
|
-
FROM "${targetTable}"
|
|
423
|
+
FROM "${targetTable}" "${innerTableAlias}"
|
|
338
424
|
${navJoinsSQL}
|
|
339
425
|
${nestedCteJoinsSQL}
|
|
340
426
|
${whereSQL}
|
|
@@ -349,7 +435,9 @@ FROM (
|
|
|
349
435
|
* Returns a single JSON object or null, not an array.
|
|
350
436
|
*/
|
|
351
437
|
buildSingleJsonAggregation(config, lateralAlias, context) {
|
|
352
|
-
const { selectedFields, targetTable, foreignKey, sourceTable, whereClause, orderByClause, isDistinct, navigationJoins } = config;
|
|
438
|
+
const { selectedFields, targetTable, foreignKey, sourceTable, whereClause, orderByClause, isDistinct, navigationJoins, relationName } = config;
|
|
439
|
+
// Use a unique table alias to avoid conflicts with outer query tables
|
|
440
|
+
const innerTableAlias = `${lateralAlias}_${relationName}`;
|
|
353
441
|
// Helper to collect all leaf fields from a potentially nested structure
|
|
354
442
|
const collectLeafFields = (fields, prefix = '') => {
|
|
355
443
|
const result = [];
|
|
@@ -381,38 +469,46 @@ FROM (
|
|
|
381
469
|
};
|
|
382
470
|
// Collect all leaf fields for the SELECT clause
|
|
383
471
|
const leafFields = collectLeafFields(selectedFields);
|
|
384
|
-
//
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
472
|
+
// Helper to rewrite expressions that reference the collection's table to use inner alias
|
|
473
|
+
const rewriteTableReference = (expression) => {
|
|
474
|
+
// Replace the special marker alias `"__collection_tableName__".` with `"innerTableAlias".`
|
|
475
|
+
const markerPattern = new RegExp(`"__collection_${targetTable}__"\\.`, 'g');
|
|
476
|
+
return expression.replace(markerPattern, `"${innerTableAlias}".`);
|
|
477
|
+
};
|
|
478
|
+
// Build the subquery SELECT fields using inner table alias
|
|
388
479
|
const allSelectFields = leafFields.map(f => {
|
|
389
|
-
// If expression is just a quoted column name (e.g., `"id"`), qualify it with target table
|
|
390
|
-
// But if it's already qualified (e.g., `"user"."username"`), leave it as is
|
|
391
480
|
const isSimpleColumn = /^"[^".]+"$/.test(f.expression);
|
|
392
|
-
if (isSimpleColumn
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return `"${targetTable}"."${columnName}" as "${f.alias}"`;
|
|
481
|
+
if (isSimpleColumn) {
|
|
482
|
+
const columnName = f.expression.slice(1, -1);
|
|
483
|
+
return `"${innerTableAlias}"."${columnName}" as "${f.alias}"`;
|
|
396
484
|
}
|
|
397
|
-
|
|
398
|
-
|
|
485
|
+
const rewritten = rewriteTableReference(f.expression);
|
|
486
|
+
if (rewritten !== `"${f.alias}"`) {
|
|
487
|
+
return `${rewritten} as "${f.alias}"`;
|
|
399
488
|
}
|
|
400
|
-
return
|
|
489
|
+
return rewritten;
|
|
401
490
|
});
|
|
402
491
|
// Build the JSONB fields for json_build_object
|
|
403
492
|
const jsonbObjectExpr = buildJsonbObject(selectedFields);
|
|
404
493
|
// Build navigation JOINs for multi-level navigation
|
|
405
|
-
const navJoinsSQL = this.
|
|
494
|
+
const navJoinsSQL = this.buildNavigationJoinsWithAlias(navigationJoins, innerTableAlias, targetTable, context);
|
|
406
495
|
// Collect nested CTE/LATERAL joins (for collections within collections)
|
|
407
496
|
const nestedCteJoins = this.collectNestedCteJoins(selectedFields);
|
|
408
497
|
const nestedCteJoinsSQL = nestedCteJoins.length > 0 ? nestedCteJoins.join('\n ') : '';
|
|
498
|
+
// For nested collections, the source table may be aliased in a parent LATERAL
|
|
499
|
+
const effectiveSourceTable = context.lateralTableAliasMap?.get(sourceTable) || sourceTable;
|
|
409
500
|
// Build WHERE clause - LATERAL correlates with parent via foreign key
|
|
410
|
-
let whereSQL = `WHERE "${
|
|
501
|
+
let whereSQL = `WHERE "${innerTableAlias}"."${foreignKey}" = "${effectiveSourceTable}"."id"`;
|
|
411
502
|
if (whereClause) {
|
|
412
|
-
|
|
503
|
+
const rewrittenWhereClause = rewriteTableReference(whereClause);
|
|
504
|
+
whereSQL += ` AND ${rewrittenWhereClause}`;
|
|
413
505
|
}
|
|
414
506
|
// Build ORDER BY clause
|
|
415
|
-
|
|
507
|
+
let orderBySQL = '';
|
|
508
|
+
if (orderByClause) {
|
|
509
|
+
const rewrittenOrderBy = rewriteTableReference(orderByClause);
|
|
510
|
+
orderBySQL = `ORDER BY ${rewrittenOrderBy}`;
|
|
511
|
+
}
|
|
416
512
|
// Build DISTINCT clause
|
|
417
513
|
const distinctClause = isDistinct ? 'DISTINCT ' : '';
|
|
418
514
|
// For single result, use row_to_json on the first row
|
|
@@ -421,7 +517,7 @@ FROM (
|
|
|
421
517
|
SELECT ${jsonbObjectExpr} as data
|
|
422
518
|
FROM (
|
|
423
519
|
SELECT ${distinctClause}${allSelectFields.join(', ')}
|
|
424
|
-
FROM "${targetTable}"
|
|
520
|
+
FROM "${targetTable}" "${innerTableAlias}"
|
|
425
521
|
${navJoinsSQL}
|
|
426
522
|
${nestedCteJoinsSQL}
|
|
427
523
|
${whereSQL}
|
|
@@ -435,34 +531,44 @@ FROM (
|
|
|
435
531
|
* Build array aggregation using LATERAL (for toNumberList/toStringList)
|
|
436
532
|
*/
|
|
437
533
|
buildArrayAggregation(config, lateralAlias, context) {
|
|
438
|
-
const { arrayField, targetTable, foreignKey, sourceTable, whereClause, orderByClause, limitValue, offsetValue, isDistinct, navigationJoins, selectedFields } = config;
|
|
534
|
+
const { arrayField, targetTable, foreignKey, sourceTable, whereClause, orderByClause, limitValue, offsetValue, isDistinct, navigationJoins, selectedFields, relationName } = config;
|
|
439
535
|
if (!arrayField) {
|
|
440
536
|
throw new Error('arrayField is required for array aggregation');
|
|
441
537
|
}
|
|
442
|
-
|
|
538
|
+
// Use a unique table alias to avoid conflicts with outer query tables
|
|
539
|
+
const innerTableAlias = `${lateralAlias}_${relationName}`;
|
|
540
|
+
// Helper to rewrite expressions that reference the collection's table to use inner alias
|
|
541
|
+
const rewriteTableReference = (expression) => {
|
|
542
|
+
// Replace the special marker alias `"__collection_tableName__".` with `"innerTableAlias".`
|
|
543
|
+
const markerPattern = new RegExp(`"__collection_${targetTable}__"\\.`, 'g');
|
|
544
|
+
return expression.replace(markerPattern, `"${innerTableAlias}".`);
|
|
545
|
+
};
|
|
443
546
|
// Get the actual field expression from selectedFields (if available)
|
|
444
547
|
// This handles navigation properties like p.user!.id which need to be "user"."id"
|
|
445
|
-
let fieldExpression = `"${arrayField}"`;
|
|
548
|
+
let fieldExpression = `"${innerTableAlias}"."${arrayField}"`;
|
|
446
549
|
if (selectedFields && selectedFields.length > 0) {
|
|
447
550
|
const firstField = selectedFields[0];
|
|
448
551
|
if (firstField.expression && firstField.expression !== `"${arrayField}"`) {
|
|
449
|
-
// Use the actual expression
|
|
450
|
-
fieldExpression = firstField.expression;
|
|
451
|
-
}
|
|
452
|
-
else if (hasNavigationJoins) {
|
|
453
|
-
// If we have navigation joins but no explicit expression, qualify with target table
|
|
454
|
-
fieldExpression = `"${targetTable}"."${arrayField}"`;
|
|
552
|
+
// Use the actual expression, rewriting target table references
|
|
553
|
+
fieldExpression = rewriteTableReference(firstField.expression);
|
|
455
554
|
}
|
|
456
555
|
}
|
|
457
556
|
// Build navigation JOINs for multi-level navigation
|
|
458
|
-
const navJoinsSQL = this.
|
|
557
|
+
const navJoinsSQL = this.buildNavigationJoinsWithAlias(navigationJoins, innerTableAlias, targetTable, context);
|
|
558
|
+
// For nested collections, the source table may be aliased in a parent LATERAL
|
|
559
|
+
const effectiveSourceTable = context.lateralTableAliasMap?.get(sourceTable) || sourceTable;
|
|
459
560
|
// Build WHERE clause with LATERAL correlation
|
|
460
|
-
let whereSQL = `WHERE "${
|
|
561
|
+
let whereSQL = `WHERE "${innerTableAlias}"."${foreignKey}" = "${effectiveSourceTable}"."id"`;
|
|
461
562
|
if (whereClause) {
|
|
462
|
-
|
|
563
|
+
const rewrittenWhereClause = rewriteTableReference(whereClause);
|
|
564
|
+
whereSQL += ` AND ${rewrittenWhereClause}`;
|
|
463
565
|
}
|
|
464
566
|
// Build ORDER BY clause
|
|
465
|
-
|
|
567
|
+
let orderBySQL = '';
|
|
568
|
+
if (orderByClause) {
|
|
569
|
+
const rewrittenOrderBy = rewriteTableReference(orderByClause);
|
|
570
|
+
orderBySQL = `ORDER BY ${rewrittenOrderBy}`;
|
|
571
|
+
}
|
|
466
572
|
// Build LIMIT/OFFSET
|
|
467
573
|
let limitOffsetClause = '';
|
|
468
574
|
if (limitValue !== undefined) {
|
|
@@ -480,7 +586,7 @@ SELECT array_agg(
|
|
|
480
586
|
) as data
|
|
481
587
|
FROM (
|
|
482
588
|
SELECT ${distinctClause}${fieldExpression} as "${arrayField}"
|
|
483
|
-
FROM "${targetTable}"
|
|
589
|
+
FROM "${targetTable}" "${innerTableAlias}"
|
|
484
590
|
${navJoinsSQL}
|
|
485
591
|
${whereSQL}
|
|
486
592
|
${orderBySQL}
|
|
@@ -493,11 +599,22 @@ FROM (
|
|
|
493
599
|
* Build scalar aggregation using LATERAL (COUNT, MIN, MAX, SUM)
|
|
494
600
|
*/
|
|
495
601
|
buildScalarAggregation(config, lateralAlias, context) {
|
|
496
|
-
const { aggregationType, aggregateField, targetTable, foreignKey, sourceTable, whereClause } = config;
|
|
602
|
+
const { aggregationType, aggregateField, targetTable, foreignKey, sourceTable, whereClause, relationName } = config;
|
|
603
|
+
// Use a unique table alias to avoid conflicts with outer query tables
|
|
604
|
+
const innerTableAlias = `${lateralAlias}_${relationName}`;
|
|
605
|
+
// Helper to rewrite expressions that reference the collection's table to use inner alias
|
|
606
|
+
const rewriteTableReference = (expression) => {
|
|
607
|
+
// Replace the special marker alias `"__collection_tableName__".` with `"innerTableAlias".`
|
|
608
|
+
const markerPattern = new RegExp(`"__collection_${targetTable}__"\\.`, 'g');
|
|
609
|
+
return expression.replace(markerPattern, `"${innerTableAlias}".`);
|
|
610
|
+
};
|
|
611
|
+
// For nested collections, the source table may be aliased in a parent LATERAL
|
|
612
|
+
const effectiveSourceTable = context.lateralTableAliasMap?.get(sourceTable) || sourceTable;
|
|
497
613
|
// Build WHERE clause with LATERAL correlation
|
|
498
|
-
let whereSQL = `WHERE "${
|
|
614
|
+
let whereSQL = `WHERE "${innerTableAlias}"."${foreignKey}" = "${effectiveSourceTable}"."id"`;
|
|
499
615
|
if (whereClause) {
|
|
500
|
-
|
|
616
|
+
const rewrittenWhereClause = rewriteTableReference(whereClause);
|
|
617
|
+
whereSQL += ` AND ${rewrittenWhereClause}`;
|
|
501
618
|
}
|
|
502
619
|
// Build aggregation expression
|
|
503
620
|
let aggregateExpression;
|
|
@@ -511,14 +628,14 @@ FROM (
|
|
|
511
628
|
if (!aggregateField) {
|
|
512
629
|
throw new Error(`${aggregationType.toUpperCase()} requires an aggregate field`);
|
|
513
630
|
}
|
|
514
|
-
aggregateExpression = `${aggregationType.toUpperCase()}("${aggregateField}")`;
|
|
631
|
+
aggregateExpression = `${aggregationType.toUpperCase()}("${innerTableAlias}"."${aggregateField}")`;
|
|
515
632
|
break;
|
|
516
633
|
default:
|
|
517
634
|
throw new Error(`Unknown aggregation type: ${aggregationType}`);
|
|
518
635
|
}
|
|
519
636
|
const lateralSQL = `
|
|
520
637
|
SELECT ${aggregateExpression} as data
|
|
521
|
-
FROM "${targetTable}"
|
|
638
|
+
FROM "${targetTable}" "${innerTableAlias}"
|
|
522
639
|
${whereSQL}
|
|
523
640
|
`.trim();
|
|
524
641
|
return lateralSQL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lateral-collection-strategy.js","sourceRoot":"","sources":["../../../src/query/strategies/lateral-collection-strategy.ts"],"names":[],"mappings":";;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAa,yBAAyB;IACpC,OAAO;QACL,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iBAAiB;QACf,+EAA+E;QAC/E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gBAAgB,CACd,MAAmC,EACnC,OAAqB;QAErB,MAAM,YAAY,GAAG,WAAW,MAAM,CAAC,OAAO,EAAE,CAAC;QAEjD,uEAAuE;QACvE,+DAA+D;QAC/D,yEAAyE;QACzE,6CAA6C;QAC7C,MAAM,qBAAqB,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAEpE,IAAI,qBAAqB,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,kCAAkC,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,UAAkB,CAAC;QACvB,IAAI,gBAAwB,CAAC;QAE7B,QAAQ,MAAM,CAAC,eAAe,EAAE,CAAC;YAC/B,KAAK,OAAO;gBACV,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;oBAC1B,gEAAgE;oBAChE,UAAU,GAAG,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;oBAC5E,gBAAgB,GAAG,IAAI,YAAY,QAAQ,CAAC,CAAE,oCAAoC;gBACpF,CAAC;qBAAM,CAAC;oBACN,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;oBACvE,gBAAgB,GAAG,aAAa,YAAY,WAAW,MAAM,CAAC,YAAY,GAAG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U;UACnD,WAAW;IACjB,WAAW;IACX,QAAQ;IACR,UAAU;IACV,iBAAiB;;KAEhB,CAAC,IAAI,EAAE,CAAC;QAET,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;OAEG;IACK,sBAAsB,CAC5B,MAAmC,EACnC,YAAoB,EACpB,OAAqB;QAErB,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;QAEtG,8CAA8C;QAC9C,IAAI,QAAQ,GAAG,UAAU,WAAW,MAAM,UAAU,QAAQ,WAAW,QAAQ,CAAC;QAChF,IAAI,WAAW,EAAE,CAAC;YAChB,QAAQ,IAAI,QAAQ,WAAW,EAAE,CAAC;QACpC,CAAC;QAED,+BAA+B;QAC/B,IAAI,mBAA2B,CAAC;QAChC,QAAQ,eAAe,EAAE,CAAC;YACxB,KAAK,OAAO;gBACV,mBAAmB,GAAG,UAAU,CAAC;gBACjC,MAAM;YACR,KAAK,KAAK,CAAC;YACX,KAAK,KAAK,CAAC;YACX,KAAK,KAAK;gBACR,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,MAAM,IAAI,KAAK,CAAC,GAAG,eAAe,CAAC,WAAW,EAAE,8BAA8B,CAAC,CAAC;gBAClF,CAAC;gBACD,mBAAmB,GAAG,GAAG,eAAe,CAAC,WAAW,EAAE,KAAK,cAAc,IAAI,CAAC;gBAC9E,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,eAAe,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,UAAU,GAAG;SACd,mBAAmB;QACpB,WAAW;EACjB,QAAQ;KACL,CAAC,IAAI,EAAE,CAAC;QAET,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAhkBD,8DAgkBC"}
|
|
1
|
+
{"version":3,"file":"lateral-collection-strategy.js","sourceRoot":"","sources":["../../../src/query/strategies/lateral-collection-strategy.ts"],"names":[],"mappings":";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GAAG,UAAU,eAAe,MAAM,UAAU,QAAQ,oBAAoB,QAAQ,CAAC;QAC7F,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;YAChE,QAAQ,IAAI,QAAQ,oBAAoB,EAAE,CAAC;QAC7C,CAAC;QAED,+BAA+B;QAC/B,IAAI,mBAA2B,CAAC;QAChC,QAAQ,eAAe,EAAE,CAAC;YACxB,KAAK,OAAO;gBACV,mBAAmB,GAAG,UAAU,CAAC;gBACjC,MAAM;YACR,KAAK,KAAK,CAAC;YACX,KAAK,KAAK,CAAC;YACX,KAAK,KAAK;gBACR,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,MAAM,IAAI,KAAK,CAAC,GAAG,eAAe,CAAC,WAAW,EAAE,8BAA8B,CAAC,CAAC;gBAClF,CAAC;gBACD,mBAAmB,GAAG,GAAG,eAAe,CAAC,WAAW,EAAE,KAAK,eAAe,MAAM,cAAc,IAAI,CAAC;gBACnG,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,eAAe,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,UAAU,GAAG;SACd,mBAAmB;QACpB,WAAW,MAAM,eAAe;EACtC,QAAQ;KACL,CAAC,IAAI,EAAE,CAAC;QAET,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA9sBD,8DA8sBC"}
|
|
@@ -38,6 +38,11 @@ import { QueryContext } from '../query-builder';
|
|
|
38
38
|
*/
|
|
39
39
|
export declare class TempTableCollectionStrategy implements ICollectionStrategy {
|
|
40
40
|
getType(): CollectionStrategyType;
|
|
41
|
+
/**
|
|
42
|
+
* Helper to rewrite the collection marker alias to the actual table name
|
|
43
|
+
* For temp table strategy, we use the actual table name (no aliasing), so marker becomes table name
|
|
44
|
+
*/
|
|
45
|
+
private rewriteCollectionMarker;
|
|
41
46
|
requiresParentIds(): boolean;
|
|
42
47
|
buildAggregation(config: CollectionAggregationConfig, context: QueryContext, client: DatabaseClient): Promise<CollectionAggregationResult>;
|
|
43
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temptable-collection-strategy.d.ts","sourceRoot":"","sources":["../../../src/query/strategies/temptable-collection-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAE5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,2BAA4B,YAAW,mBAAmB;IACrE,OAAO,IAAI,sBAAsB;IAIjC,iBAAiB,IAAI,OAAO;IAKtB,gBAAgB,CACpB,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,2BAA2B,CAAC;IAevC;;;;;;OAMG;YACW,8BAA8B;IA6G5C;;;OAGG;YACW,sBAAsB;IAsEpC;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAsC3B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAsBjC;;;;;;OAMG;IACH,OAAO,CAAC,yCAAyC;IAsCjD;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;
|
|
1
|
+
{"version":3,"file":"temptable-collection-strategy.d.ts","sourceRoot":"","sources":["../../../src/query/strategies/temptable-collection-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAE5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,2BAA4B,YAAW,mBAAmB;IACrE,OAAO,IAAI,sBAAsB;IAIjC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAM/B,iBAAiB,IAAI,OAAO;IAKtB,gBAAgB,CACpB,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,2BAA2B,CAAC;IAevC;;;;;;OAMG;YACW,8BAA8B;IA6G5C;;;OAGG;YACW,sBAAsB;IAsEpC;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAsC3B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAsBjC;;;;;;OAMG;IACH,OAAO,CAAC,yCAAyC;IAsCjD;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAyD5B;;OAEG;IACH,OAAO,CAAC,iCAAiC;IA4CzC;;;OAGG;IACH,OAAO,CAAC,WAAW;IA0BnB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IA6DhC;;OAEG;IACH,OAAO,CAAC,qCAAqC;IAsC7C;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IA4ChC;;OAEG;IACH,OAAO,CAAC,qCAAqC;IAmC7C;;OAEG;IACH,OAAO,CAAC,yBAAyB;CAyClC"}
|
|
@@ -40,6 +40,16 @@ class TempTableCollectionStrategy {
|
|
|
40
40
|
getType() {
|
|
41
41
|
return 'temptable';
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Helper to rewrite the collection marker alias to the actual table name
|
|
45
|
+
* For temp table strategy, we use the actual table name (no aliasing), so marker becomes table name
|
|
46
|
+
*/
|
|
47
|
+
rewriteCollectionMarker(expr, targetTable) {
|
|
48
|
+
if (!expr)
|
|
49
|
+
return expr;
|
|
50
|
+
const markerPattern = new RegExp(`"__collection_${targetTable}__"`, 'g');
|
|
51
|
+
return expr.replace(markerPattern, `"${targetTable}"`);
|
|
52
|
+
}
|
|
43
53
|
requiresParentIds() {
|
|
44
54
|
// Temp table strategy requires parent IDs to be fetched first
|
|
45
55
|
return true;
|
|
@@ -341,12 +351,16 @@ ${aggregationSQL}
|
|
|
341
351
|
return result;
|
|
342
352
|
};
|
|
343
353
|
const leafFields = collectLeafFields(selectedFields);
|
|
344
|
-
// Build SELECT fields
|
|
354
|
+
// Build SELECT fields (rewrite collection markers)
|
|
345
355
|
const selectFields = leafFields
|
|
346
|
-
.map(f =>
|
|
356
|
+
.map(f => {
|
|
357
|
+
const rewrittenExpr = this.rewriteCollectionMarker(f.expression, targetTable) || f.expression;
|
|
358
|
+
return `${rewrittenExpr} as "${f.alias}"`;
|
|
359
|
+
})
|
|
347
360
|
.join(', ');
|
|
348
|
-
// Build WHERE clause
|
|
349
|
-
const
|
|
361
|
+
// Build WHERE clause (rewrite collection markers)
|
|
362
|
+
const rewrittenWhereClause = this.rewriteCollectionMarker(whereClause, targetTable);
|
|
363
|
+
const additionalWhere = rewrittenWhereClause ? ` AND ${rewrittenWhereClause}` : '';
|
|
350
364
|
// Build ORDER BY clause
|
|
351
365
|
const orderBySQL = orderByClause ? `ORDER BY ${orderByClause}` : `ORDER BY "id" DESC`;
|
|
352
366
|
// If LIMIT or OFFSET is specified, use ROW_NUMBER() for per-parent pagination
|
|
@@ -466,8 +480,9 @@ ${orderBySQL.replace(/ORDER BY/i, 'ORDER BY')}
|
|
|
466
480
|
};
|
|
467
481
|
// Build the JSONB fields for json_build_object (handles nested structures)
|
|
468
482
|
const jsonbObjectExpr = buildJsonbObject(selectedFields);
|
|
469
|
-
// Build WHERE clause (combine temp table join with additional filters)
|
|
470
|
-
const
|
|
483
|
+
// Build WHERE clause (combine temp table join with additional filters, rewrite markers)
|
|
484
|
+
const rewrittenWhereClause = this.rewriteCollectionMarker(whereClause, targetTable);
|
|
485
|
+
const additionalWhere = rewrittenWhereClause ? ` AND ${rewrittenWhereClause}` : '';
|
|
471
486
|
// Build ORDER BY clause (use primary key DESC as default for consistent ordering matching JSONB)
|
|
472
487
|
const orderBySQL = orderByClause ? `ORDER BY ${orderByClause}` : `ORDER BY "id" DESC`;
|
|
473
488
|
// Build json_agg ORDER BY clause (uses aliases since it operates on subquery output)
|
|
@@ -536,8 +551,9 @@ GROUP BY t."${foreignKey}"
|
|
|
536
551
|
if (!arrayField) {
|
|
537
552
|
throw new Error('arrayField is required for array aggregation');
|
|
538
553
|
}
|
|
539
|
-
// Build WHERE clause
|
|
540
|
-
const
|
|
554
|
+
// Build WHERE clause (rewrite collection markers)
|
|
555
|
+
const rewrittenWhereClause = this.rewriteCollectionMarker(whereClause, targetTable);
|
|
556
|
+
const additionalWhere = rewrittenWhereClause ? ` AND ${rewrittenWhereClause}` : '';
|
|
541
557
|
// Build ORDER BY clause (use primary key DESC as default for consistent ordering matching JSONB)
|
|
542
558
|
const orderBySQL = orderByClause ? `ORDER BY ${orderByClause}` : `ORDER BY "id" DESC`;
|
|
543
559
|
// Build array_agg ORDER BY clause (uses aliases since it operates on subquery output)
|
|
@@ -596,8 +612,9 @@ GROUP BY t."${foreignKey}"
|
|
|
596
612
|
*/
|
|
597
613
|
buildScalarAggregationSQL(config, tempTableName) {
|
|
598
614
|
const { aggregationType, aggregateField, targetTable, foreignKey, whereClause } = config;
|
|
599
|
-
// Build WHERE clause
|
|
600
|
-
const
|
|
615
|
+
// Build WHERE clause (rewrite collection markers)
|
|
616
|
+
const rewrittenWhereClause = this.rewriteCollectionMarker(whereClause, targetTable);
|
|
617
|
+
const additionalWhere = rewrittenWhereClause ? ` AND ${rewrittenWhereClause}` : '';
|
|
601
618
|
// Build aggregation expression
|
|
602
619
|
// Use targetTable as alias to match field references in whereClause
|
|
603
620
|
let aggregateExpression;
|