Repository navigation
fix(sql): suggest columns inside select-list function calls (Fixes #10170) - #10275
Conversation
Typing SUM(CNKI_DOW after an earlier projection returned no column suggestions. The select-list scanner tracked the open SELECT per paren depth, so inside SUM( the depth-1 group never saw the depth-0 SELECT, and the word-based fallback only looks for SELECT among the last three words, which misses once another projection precedes the call. The scanner now also reports when the cursor sits in a paren group nested in an open select list. That feeds column suggestions only; select-list-only items (table.* snippets, batch selection) stay limited to the top-level select list. Fixes t8y2#10170
t8y2
left a comment
There was a problem hiding this comment.
Well-scoped fix — verified it reaches the live editor path: for a prefix after SUM( the semantic classifier returns a low-confidence keyword intent, so the legacy context this PR fixes is what actually drives suggestions. Traced the nested-depth inheritance through subqueries in the select list, CTEs, UNION, OVER (PARTITION BY ...), and HAVING — all keep prior behavior, and keeping table.* snippets and batch selection top-level-only is pinned by the new test.
One non-blocking nit: isInColumnContext still re-runs the scan through isInSelectListContext even though getSqlCompletionContext already has the result; threading the precomputed flag through would avoid the duplicate pass.
Two pre-existing (unchanged) gaps you may want to file separately: the scanner doesn't mask --//* */ comments, and a FROM inside select-list parens (e.g. EXTRACT(x FROM ...)) clears the nested flag.
Thanks for the clean fix and the regression tests.
|
Thanks for the contribution! Merged in 26e6db1, will be released in the next version. |
变更说明 / Change Description
The failing case is the one in the screenshot, with a projection before the aggregate:
SELECT SUM(A) AS a, SUM(CNKI_DOW|. InsideSUM(the select-list scanner loses the open SELECT, and the fallback only looks back three words. The scanner now also reports a paren group nested in an open select list, which turns on column suggestions only;table.*snippets and batch selection stay top-level.变更类型 / Change Type
涉及前端 / Frontend Changes
No visual change.
验证 / Validation
make check通过 /make checkpassesmake cargo-check-fast通过 /make cargo-check-fastpassesFour new cases in
sqlCompletion.context.spec.ts(164 -> 168 passing) fail with the fix reverted. Format, lint and typecheck pass; the only vitest failures were load timeouts in unrelated specs that pass alone. No Rust changed.关联 Issue / Related Issue
Close #10170