Repository navigation
feat(alerts): per-connection and per-database alert overrides - #236
Merged
Merged
Conversation
Adds a three-level hierarchy for the query confirmation alert mode:
database override > connection override > global. The resolver falls
back upward when a scope has nothing set.
- store connection-level overrides in ConnectionConfig.options
- store database-level overrides in settings.json keyed by
"{connection}::{database}"
- :alert grows scope arguments: ":alert connection write",
":alert database unset", etc.
- new "sqlit alerts list|set|unset" CLI subcommand
- "--alert" flag on "connections add/edit" and "connect" provider parsers
Beefs up coverage for the alert hierarchy: - :alert shell handler — scope routing (global/connection/database/db alias), set/unset/clear/default aliases, missing-active-connection and missing-active-database error paths, status display - query_execution._maybe_confirm_query — directly drive the method to confirm that connection overrides relax/tighten global, that db overrides win, and that overrides keyed at one connection or db do not bleed into another - sqlit alerts CLI — invalid mode, --database without --connection, global unset, idempotent unset of absent overrides, alerts list with mixed scopes; blank --alert value treated as no-op
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.
Adds a three-level hierarchy for the query confirmation alert mode: database > connection > global, falling back upward when a scope has nothing set.
Today
:alert deleteis a single global switch — useful, but coarse. With this PR you can keep alerts off on your dev sqlite, require confirmation for writes on a shared dev Postgres, and require confirmation on deletes for a specific prod database — all at the same time, with the most-specific scope winning.Configuration
In the TUI — extended
:alertcommand::alert— show effective mode + every scope:alert off|delete|write— set global (back-compat with the old form):alert connection off|delete|write|unset— current connection:alert database off|delete|write|unset— current connection's active database:alert global ...— explicit globalOn the CLI — new
alertssubcommand:sqlit alerts listsqlit alerts set <mode> [--connection NAME] [--database DB]sqlit alerts unset [--connection NAME] [--database DB]Plus
--alert MODEonconnections add,connections edit, andconnect <provider>for setting the per-connection override at create/edit time.Storage
settings.jsonunderquery_alert_mode(unchanged).ConnectionConfig.options["query_alert_mode"], so they travel with the saved connection.settings.jsonunderquery_alert_modes_by_database, keyed by"{connection}::{database}".Tests
44 new tests across four files:
test_query_alerts_hierarchy.py— resolver + CLI handlerstest_alert_command_handler.py—:alertshell command (scope routing, error paths, aliases)test_query_confirm_integration.py— drives the real_maybe_confirm_queryto verify the wiring, not just the helpertest_query_alerts.py— unchanged, still passesTotal unit suite: 1009 passing (was 976).