Skip to content

feat(525): react to DROP DATABASE executed inside the app - #535

Merged
debba merged 1 commit into
TabularisDB:mainfrom
gcapellib:feat/525-drop-database-detection-full
Jul 26, 2026
Merged

feat(525): react to DROP DATABASE executed inside the app#535
debba merged 1 commit into
TabularisDB:mainfrom
gcapellib:feat/525-drop-database-detection-full

Conversation

@gcapellib

Copy link
Copy Markdown
Contributor

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-executed DROP DATABASE/DROP SCHEMA and 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_query and execute_query_batch (the import path), detected before the sanitized query is moved into the spawn. On success, emits database-dropped with the connection id and database name.

DatabaseProvider listens and calls refreshDatabaseSelection (from #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 write. The main window is the stable anchor since dedicated connection windows close with their connection.

refreshDatabaseSelection gains a notifyWhenUnchanged option (default true, matching the manual-click behaviour from #530) so the automatic path stays silent when there's nothing to reconcile — found by testing a DROP on 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 --force all clean.

Not covered here

Single-database session teardown and the disconnect_connection pool leak, per the issue's scope — happy to follow up once this lands.

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
debba force-pushed the feat/525-drop-database-detection-full branch from 1bcae68 to 717225e Compare July 26, 2026 13:40
@debba
debba merged commit 715239b into TabularisDB:main Jul 26, 2026
2 checks passed
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.

React to DROP DATABASE executed inside the app

2 participants