Skip to content

Commit 00b5ff4

Browse files
author
Dylan Bobby Storey
committed
docs(metis): T-0309 iter-39 update — projector fix works, result-renderer also intercepts edge
Iter 39 attempted the projector branch (transform_match marks varlen rel vars with cte_name, transform_return emits json_group_array over path_ids). The generated SQL prepares and executes cleanly — no more 'no such column' errors. But the result is still wrong because build_query_results / executor_result_project intercept edge-typed columns and re-fetch by edge_id from the column's integer value, ignoring the JSON array our SQL produced. The complete fix needs both: 1. The projector branch (this iter, reverted because partial). 2. build_query_results detecting varlen-bound edge vars and skipping the per-edge-id re-fetch. Doc updated with the layered finding so the next attempt has the full picture.
1 parent f331bb2 commit 00b5ff4

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

.metis/backlog/bugs/GQLITE-T-0309.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,50 @@ fix. ~22 error scenarios share this root cause.
108108
- [ ] 22 `_gql_default_alias` errors in TCK flip to pass (or to a
109109
different fail).
110110

111+
## Iter 39 attempt — partial: projector fixed, result-renderer still wrong
112+
113+
Implemented the projector branch:
114+
- transform_match.c (line ~1145, inside the `rel->varlen` block):
115+
call `transform_var_set_cte(ctx->var_ctx, rel->variable, cte_name)`
116+
to stamp the varlen rel variable.
117+
- transform_return.c (line ~956): when projecting an edge variable
118+
whose `cte_name` is set, emit
119+
`(SELECT json_group_array(json_object(...)) FROM edges e WHERE e.id IN (json_each path_ids) ORDER BY instr(...))`
120+
instead of the single-edge JSON template.
121+
122+
Verified the **generated SQL is correct**: it prepares and runs (no
123+
more "no such column" errors). But the rendered result is still wrong:
124+
125+
```
126+
MATCH (a)-[r*1..1]->(b) RETURN r
127+
=> [{"r": {"id": 0, "type": "", "startNode": 0, "endNode": 0, "properties": {}}}]
128+
(one row, edge object with all-zero fields)
129+
```
130+
131+
Expected:
132+
133+
```
134+
=> [{"r": [{"id": 1, "type": "T", "startNodeId": ..., "endNodeId": ..., "properties": {}}]}]
135+
(one row, value is a JSON array with one edge object)
136+
```
137+
138+
Root cause of the residual: **build_query_results in
139+
executor_match.c reads the variable kind from the RETURN AST and
140+
re-fetches edges by id from the column's integer value**. It doesn't
141+
know to treat varlen-bound edge variables as already-rendered JSON
142+
arrays. The fetch path is in `executor_result_project.c` around
143+
line 425 (`edge_id >= 0` branch).
144+
145+
The complete fix needs:
146+
1. The projector branch (done in iter 39, reverted because it doesn't
147+
help alone).
148+
2. Detect varlen-bound edge vars in `build_query_results` and skip
149+
the per-edge-id re-fetch — use the column's text value verbatim
150+
as the JSON array.
151+
152+
Reverted iter 39 because partial fix leaves TCK identical with extra
153+
churn. Full fix is the next attempt.
154+
111155
## Discovered
112156

113157
2026-05-21 during iteration 38 of the open-work queue, dumping the

0 commit comments

Comments
 (0)