Skip to content

Conversation

@Artmann
Copy link

@Artmann Artmann commented Nov 28, 2025

Table names were not being suggested when the cursor was positioned right after FROM or JOIN keywords with no table typed yet. This adds detection for cursor position after these keywords using the parsed FROM clause's after field.

Supports all JOIN types: INNER, LEFT, RIGHT, FULL, FULL OUTER, CROSS, NATURAL, and plain JOIN.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced SQL editor's table name autocomplete suggestions with improved cursor position detection when working within FROM and JOIN clauses, including detection immediately following FROM/JOIN keywords for more accurate completions during query composition
  • Tests

    • Added comprehensive test coverage for table name autocompletion scenarios across various FROM and JOIN clause configurations, including different JOIN types, spacing patterns, and multi-line query formatting

✏️ Tip: You can customize this high-level summary in your review settings.

Table names were not being suggested when the cursor was positioned
right after FROM or JOIN keywords with no table typed yet. This adds
detection for cursor position after these keywords using the parsed
FROM clause's `after` field.

Supports all JOIN types: INNER, LEFT, RIGHT, FULL, FULL OUTER, CROSS,
NATURAL, and plain JOIN.
@coderabbitai
Copy link

coderabbitai bot commented Nov 28, 2025

📝 Walkthrough

Walkthrough

This PR enhances SQL table-name completion in the autocomplete system. The code now detects cursor position within FROM/JOIN clauses more precisely, suggesting table candidates both inside these clauses and immediately after the FROM or JOIN keywords. The addCandidatesForSelectQuery function signature was updated to accept parsed FROM clause data, enabling this refined logic. Two call sites were adjusted to pass this information where needed. Comprehensive test cases were added to verify completion behavior across various FROM and JOIN clause scenarios.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title directly matches the PR's main objective: enabling table name autocomplete after FROM/JOIN keywords.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between eb6ba0f and 23ee7a8.

📒 Files selected for processing (2)
  • packages/server/src/complete/complete.ts (3 hunks)
  • packages/server/test/complete.test.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/server/src/complete/complete.ts (1)
packages/sql-parser/index.d.ts (2)
  • ParseError (60-60)
  • FromTableNode (436-436)
🔇 Additional comments (4)
packages/server/src/complete/complete.ts (3)

114-114: LGTM!

The call site correctly passes parsedFromClause within a guarded block where it's guaranteed non-null.


242-246: LGTM!

Method signature update is consistent with the updated call site.


270-284: The review's core technical claim is incorrect: the regex alternation bug does not exist, and 'FULL OUTER JOIN' is correctly matched by the current pattern.

Testing confirms that 'FULL OUTER JOIN ' successfully matches the regex pattern /^(INNER |LEFT |RIGHT |FULL |FULL OUTER |CROSS |NATURAL |OUTER )?JOIN( |$)/. JavaScript regex engines use backtracking, so when 'FULL ' alone fails to complete a match, the engine backtracks and tries 'FULL OUTER ', which succeeds. The test case at line 344-351 ('SELECT * FROM TABLE1 FULL OUTER JOIN ' at column 37) correctly expects table completion and would pass.

The suggested fix (reordering to place FULL OUTER before FULL ) is unnecessary.

However, the regex does have real limitations: it does not support LEFT OUTER JOIN, RIGHT OUTER JOIN, and NATURAL + LEFT/RIGHT/FULL combinations—all valid SQL JOIN types. These are legitimate missing patterns, though not the bug the review described.

Likely an incorrect or invalid review comment.

packages/server/test/complete.test.ts (1)

244-360: Comprehensive test coverage for FROM/JOIN completion.

The test suite thoroughly covers the new feature with tests for FROM and all documented JOIN types. Tests verify that table candidates appear after keywords with trailing space, including multi-line SQL scenarios.


Comment @coderabbitai help to get the list of available commands and usage tips.

@Artmann Artmann merged commit 4f01b12 into release Nov 28, 2025
2 checks passed
@Artmann Artmann deleted the chris/fix-autocomplete-with-space branch November 28, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants