Skip to content

fix(sql): suggest columns inside select-list function calls (Fixes #10170) - #10275

Merged
t8y2 merged 3 commits into
t8y2:mainfrom
drakeo338:claude/10170-fix
Sep 28, 2026
Merged

t8y2 merged 3 commits into
t8y2:mainfrom
drakeo338:claude/10170-fix

Conversation

@drakeo338

Copy link
Copy Markdown

变更说明 / 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|. Inside SUM( 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

  • 新功能 / New feature
  • Bug 修复 / Bug fix
  • 性能优化 / Performance improvement
  • 代码重构 / Code refactoring
  • 文档更新 / Documentation
  • CI / 构建 / CI or build

涉及前端 / Frontend Changes

  • 本 PR 涉及前端改动,已附截图/录屏(见下方) / This PR includes frontend changes and screenshots or a recording are attached below.

No visual change.

验证 / Validation

  • make check 通过 / make check passes
  • make cargo-check-fast 通过 / make cargo-check-fast passes
  • 相关测试通过 / Relevant tests pass

Four 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

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
@github-actions github-actions Bot added area/desktop Desktop application or Tauri shell bug Something isn't working labels Sep 25, 2026

@t8y2 t8y2 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@t8y2
t8y2 merged commit 26e6db1 into t8y2:main Sep 28, 2026
26 checks passed
@t8y2

t8y2 commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution! Merged in 26e6db1, will be released in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/desktop Desktop application or Tauri shell bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MySQL聚合函数, 输入列名没有列名代码提示, 反而 AS 后面输入别名有代码提示

2 participants