Commit Graph

6 Commits

Author SHA1 Message Date
Puskar Basu
791ea6f181 Fix autocomplete regression: suggestions disappear when typing table name after 'from ' closes #4928 (#4929) 2026-02-06 12:08:22 +05:30
Nathan Wallace
bf3092396c executeMetaquery error handling closes #4789 (#4834)
* Add test for #4789: executeMetaquery panic instead of error

Added TestExecuteMetaquery_NotInitialised to demonstrate the bug where
executeMetaquery panics with "client is not initalised" instead of
returning an error when called before initialization completes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4789: Return error instead of panic in executeMetaquery

Replace panic("client is not initalised") with proper error return
in executeMetaquery. This prevents unrecoverable crashes when the
method is called before client initialization completes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-16 12:00:19 -05:00
Nathan Wallace
152420d278 Fix getQueryInfo() 'from ' detection closes #4810 (rebased) (#4884)
* Add test for #4810: getQueryInfo() fails to detect 'from ' correctly

This test demonstrates that getQueryInfo("from ") incorrectly returns
EditingTable = false when it should return true. This prevents autocomplete
from suggesting tables after users type "from ".

The test currently fails as expected, proving the bug exists.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4810: Correct getQueryInfo() 'from ' detection for autocomplete

This commit fixes a bug where getQueryInfo("from ") incorrectly returned
EditingTable = false, preventing autocomplete from suggesting tables after
users type "from ".

The fix involves two changes:

1. Modified getPreviousWord() to correctly return "from" when the input is
   "from " (single word followed by space). Previously, it returned an empty
   string because it couldn't find a space before "from".

2. Modified isEditingTable() to check that the text ends with a space. This
   ensures we only enable table suggestions when the user has typed "from "
   (ready for a table name), not when they're in the middle of typing "from"
   or after they've already started typing a table name like "from my_table".

The combination of these changes ensures:
- "from " → EditingTable = true (autocomplete shows tables)
- "from my_table" → EditingTable = false (autocomplete doesn't interfere)
- "from" → EditingTable = false (no space yet, not ready for table name)

All existing tests pass, and the new test from the previous commit now passes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-16 08:50:25 -05:00
Nathan Wallace
22bfc9991f initialisationComplete flag synchronized closes #4803 (rebased) (#4886)
* Add test for #4803: Race condition in initialisationComplete flag

Add TestInitialisationComplete_RaceCondition to demonstrate the data race
that occurs when the initialisationComplete boolean flag is accessed
concurrently by multiple goroutines without synchronization.

The test simulates:
- Init goroutine writing to the flag
- Query executor reading via isInitialised()
- Notification handler reading the flag directly

This test will fail when run with the -race flag, exposing the bug.

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4803: Use atomic.Bool for initialisationComplete flag

Replace the plain boolean initialisationComplete field with atomic.Bool
to prevent data races when accessed concurrently by multiple goroutines.

Changes:
- Change field type from bool to atomic.Bool
- Use .Store(true) for writes
- Use .Load() for reads in isInitialised() and handleConnectionUpdateNotification()
- Update test to use atomic operations

The test now passes with -race flag, confirming the race condition is fixed.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 10:48:46 -05:00
Nathan Wallace
2e5f3fda97 Add comprehensive passing tests from bug hunting initiative (#4864) 2025-11-13 09:26:46 +08:00
Nathan Wallace
5e1d316759 Fix #4710: Return empty slice instead of nil in getTableAndConnectionSuggestions (#4734) 2025-11-11 19:25:03 +08:00