Commit 05d0f60
fix(#209): demote a nested INNER view join under a LEFT ancestor (drop-row bug)
Follow-up to 17c26b3. The join type was derived per-hop with no ancestor
propagation, but synthesized joins render flat + left-associative — so a required
belongs-to hop BELOW a LEFT hop emitted e.g.
FROM orders o
LEFT OUTER JOIN customers c ON c.id = o.customer_id
INNER JOIN countries c0 ON c0.id = c.country_id
For an order with no customer, the LEFT yields NULL customer columns, then the
INNER's ON (c0.id = c.country_id) references the NULLed c.country_id → no match →
the base ORDER ROW IS DROPPED, where pre-#209 it survived with NULLs. Same hazard
for a has-many hop followed by a required belongs-to (an aggregate view would drop
zero-children base rows it should COALESCE). The single-hop tests didn't cover it.
Fix: an INNER hop survives only when its ENTIRE ancestor chain is INNER; otherwise
demote to LEFT. Lossless — under a LEFT ancestor, LEFT is the correct type, so
nothing is given up. Single-hop joins are unchanged (empty ancestor chain → the
`every` guard is vacuously true), so the canonical schema.postgres.sql stays
byte-identical.
Verified: new nested-chain regression test (nullable→required chain demotes to LEFT;
all-required chain stays INNER end to end); codegen-ts 957 pass; typecheck exit 0;
canonical schema drift gate byte-identical.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGQ7oSuNcjhsMHWwZzhBwr1 parent 17c26b3 commit 05d0f60
2 files changed
Lines changed: 65 additions & 3 deletions
File tree
- server/typescript/packages/codegen-ts
- src/projection
- test/projection
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
528 | 535 | | |
529 | | - | |
530 | | - | |
531 | | - | |
| 536 | + | |
532 | 537 | | |
533 | 538 | | |
534 | 539 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
63 | 120 | | |
64 | 121 | | |
65 | 122 | | |
| |||
0 commit comments