You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(sql-orm-client): drop LATERAL include codegen for correlated-only read path
The read-path include dispatch carried two single-query builders —
buildLateralIncludeArtifacts (LEFT JOIN LATERAL + json_agg) for Postgres
and buildCorrelatedIncludeProjection (correlated subquery) for SQLite —
selected on the `lateral` capability flag. Benchmarking on PG 17.5/17.10
proved the two forms compile to structurally identical plans for the
top-N-per-parent shape (the per-parent LIMIT forbids de-correlation of
either form), so LATERAL offers no planner advantage for includes.
Route every include through the correlated path and remove the strategy
axis entirely (TML-2657 already removed the multi-query fallback, so the
dispatch was binary): delete buildLateralIncludeArtifacts, drop the
`strategy` parameter from every include builder, simplify
buildNestedIncludeArtifacts to projections-only (correlated emits no
joins), rename compileSelectWithIncludeStrategy to compileSelectWithIncludes,
and delete include-strategy.ts (selectIncludeStrategy / IncludeStrategy).
The `lateral` capability flag, JoinAst.lateral, the renderer LATERAL
emission, and the public lateralJoin() DSL are independent consumers and
are untouched. A new regression guard pins that a lateral-capable
contract now resolves includes in a single execution with no LATERAL
join and no LATERAL keyword in the lowered SQL.
Refs: TML-2729
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
`combine() envelope for include "${include.relationName}" is missing (got ${raw===null ? 'null' : 'undefined'}); the LATERAL / correlated subquery should always produce a JSON object — this indicates a planner or decoder bug.`,
349
+
`combine() envelope for include "${include.relationName}" is missing (got ${raw===null ? 'null' : 'undefined'}); the correlated subquery should always produce a JSON object — this indicates a planner or decoder bug.`,
354
350
);
355
351
}
356
352
constparsed=parseIncludePayload(raw);
@@ -374,7 +370,7 @@ function describeEnvelopeShape(value: unknown): string {
374
370
375
371
/**
376
372
* Pull the primitive scalar value out of the JSON envelope emitted by
377
-
* the lateral / correlated scalar builder.
373
+
* the correlated scalar builder.
378
374
*
379
375
* Contract: the envelope is always either
380
376
* - a `{ value: <primitive> }` JSON object (the SQL path), or
@@ -393,8 +389,8 @@ function describeEnvelopeShape(value: unknown): string {
393
389
* `SUM` / `AVG` / `MIN` / `MAX` over an empty input set return SQL
394
390
* `NULL`, which surfaces as `null` here. The outer `raw === null`
395
391
* fallback is defensive cover for an empty parent set; in single-query
396
-
* dispatch the LATERAL / correlated subquery always produces a row,
397
-
* so the inner envelope's `value` is always set by SQL.
392
+
* dispatch the correlated subquery always produces a row, so the inner
0 commit comments