fix(editor): detect SQL clause at cursor so JOIN suggests tables (#1646)#1653
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
Closes #1646.
Problem
In a multi-join query, triggering autocomplete after
INNER JOINsuggested columns from the already-referenced tables instead of available table names.Root cause
SQLContextAnalyzer.determineClauseTypeclassified the cursor's clause by taking the first regex in a fixed-priority list whose greedy\bKEYWORD\s+[^;]*$body reached the cursor. That returns the highest-priority keyword present anywhere in the statement, not the clause keyword nearest the cursor. Since.onis listed before the JOIN patterns,... ON a = b INNER JOIN |matched the earlierONand was classified as the ON clause, which only suggests columns. The same flaw misfired onSET→WHERE,HAVING→ORDER BY, and every multi-join chain.Fix
CASE … END. The structural and DDL regexes (parenthesis-bounded or statement-anchored) stay as a first pass.expectsObjectNametoSQLContext, set when the cursor is in the table-operand slot ofFROM/JOIN/INTO, and used it so tables lead the list after a join instead of keywords burying them.ONclause now offers clause-transition keywords (the JOIN family, WHERE, GROUP BY, ORDER BY, ...), so typing the nextINNER JOINafter a complete join condition surfaces it instead of fuzzy-matching columns.FROM a, b, cnow puts every table in scope for column completion.No PluginKit or ABI impact;
SQLContextis app-internal. TheSQLSchemaProvideractor and its load-task invariant are untouched.Tests
SQLClauseDetectionTestscovers the full matrix: linear clauses, nearest-clause-wins (the bug and its siblings), case-insensitivity,CASE … END, parentheses and subqueries, quoted identifiers, the operand slot, string and comment guards, multi-statement, and table extraction.SQLContextAnalyzerTestsandSQLCompletionProviderTests: tables appear and rank first after JOIN,ONoffers transition keywords, and a comma-separated FROM scopes real columns to every table.Docs and changelog
docs/features/autocomplete.mdx: multi-join example and a note that the clause is detected at the cursor.