feat: sqlCompletion helper to register all completion sources at once#167
Merged
Conversation
Registering the CTE, alias-qualified, and unqualified column completion
sources required three separate dialect.language.data.of({ autocomplete })
calls. Add a sqlCompletion({ dialect, schema, parser, contextAnalyzer })
helper that wires up all three, sharing a single parser and query-context
analyzer, with per-source enable toggles. Update the demo to use it.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Registering the SQL completion sources had gotten unwieldy — each of the three schema-aware sources required its own
dialect.language.data.of({ autocomplete })call:This PR adds a convenience helper that does it in one call:
Details
sqlCompletion(config)(src/sql/completion-extension.ts) registers all three completion sources:createCteCompletionSource— CTE names + their output columnsaliasColumnCompletionSource—u.→ columns ofusersunqualifiedColumnCompletionSource—SELECT e→emailfrom FROM/JOIN tablesenableCteCompletion/enableAliasCompletion/enableColumnCompletion, all defaulttrue), mirroring theenable*pattern insqlExtension.src/index.ts(sqlCompletion,SqlCompletionConfig).It's a separate helper from
sqlExtensionbecause completion sources must be registered against a specific dialect'slanguage, whichsqlExtensiondoesn't take.Testing
src/sql/__tests__/completion-extension.test.tsverifies the helper registers all three sources by default and honors the enable/disable toggles.src/__tests__/index.test.ts.pnpm run typecheck,pnpm exec oxlint, tests, andpnpm run demobuild all pass.Summary by cubic
Introduce
sqlCompletion({ dialect, schema, parser, contextAnalyzer })to register CTE, alias-qualified, and unqualified column completions with one call. This reduces setup to a single extension and reuses one parser/context analyzer for better performance.sqlCompletion(config)to registercreateCteCompletionSource,aliasColumnCompletionSource, andunqualifiedColumnCompletionSourceagainst the provided dialect.QueryContextAnalyzer; supportsenableCteCompletion,enableAliasCompletion, andenableColumnCompletiontoggles (default true).sqlCompletionandSqlCompletionConfig; updated demo to use the helper; added tests to verify defaults and toggles.Written for commit c67e464. Summary will update on new commits.