feat(525): react to DROP DATABASE executed inside the app - #535
Merged
debba merged 1 commit intoJul 26, 2026
Merged
Conversation
Adds a small dedicated parser (sql_database_statements::dropped_database) that recognises a successfully-executed DROP DATABASE/DROP SCHEMA statement and extracts the database name — fails closed on multi-statement payloads, unquoted trailing garbage, and unclosed quotes rather than guessing. 28 unit tests, plus direct tests of the extracted helpers per rust.md rule 5. Wired into both execute_query and execute_query_batch (the import path), detected before the sanitized query is moved into the spawn. On success, emits a database-dropped event with the connection id and database name. Frontend: DatabaseProvider listens for the event and calls the refreshDatabaseSelection extracted in TabularisDB#530. Only the main window acts on it — set_selected_databases reloads and rewrites the whole connections file, and every window mounts its own provider, so letting several react risks one overwriting another's change; the main window is the stable anchor since dedicated connection windows close with their connection. refreshDatabaseSelection gains a notifyWhenUnchanged option (default true, matching TabularisDB#530's manual-click behaviour) so the automatic path stays silent when there's nothing to reconcile — surfaced by testing a DROP on a database that wasn't selected, which produced a spurious 'up to date' toast without it. Manually verified against all three cases from the issue: a selected database dropped from the app (sidebar clears, toast shown), a non-selected one (silent, as expected), and the TabularisDB#530 button still notifying on demand. Stacked on TabularisDB#530's branch since this needs refreshDatabaseSelection, which isn't in main yet.
debba
force-pushed
the
feat/525-drop-database-detection-full
branch
from
July 26, 2026 13:40
1bcae68 to
717225e
Compare
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.
Fixes #525. Stacked on #530 — this PR's diff includes #530's commit until that one merges into
main; only the second commit (feat(525): ...) is new here.What
A small dedicated parser (
sql_database_statements::dropped_database) recognises a successfully-executedDROP DATABASE/DROP SCHEMAand extracts the name — fails closed on multi-statement payloads, trailing garbage after the identifier, and unclosed quotes rather than guessing. 28 unit tests, plus direct tests of the extracted helpers (rust.md rule 5).Wired into both
execute_queryandexecute_query_batch(the import path), detected before the sanitized query is moved into the spawn. On success, emitsdatabase-droppedwith the connection id and database name.DatabaseProviderlistens and callsrefreshDatabaseSelection(from #530). Only the main window acts on it:set_selected_databasesreloads and rewrites the whole connections file, and every window mounts its own provider, so letting several react risks one overwriting another's write. The main window is the stable anchor since dedicated connection windows close with their connection.refreshDatabaseSelectiongains anotifyWhenUnchangedoption (defaulttrue, matching the manual-click behaviour from #530) so the automatic path stays silent when there's nothing to reconcile — found by testing aDROPon a database that wasn't selected, which produced a spurious "up to date" toast without it.Testing
Manually verified all three cases from the issue: a selected database dropped from the app (sidebar clears, toast shown), a non-selected one (silent), and the #530 button still notifying on demand.
cargo test sql_database_statements(28 passing),cargo check,tsc -b --forceall clean.Not covered here
Single-database session teardown and the
disconnect_connectionpool leak, per the issue's scope — happy to follow up once this lands.