Skip to content

feat(alerts): per-connection and per-database alert overrides - #236

Merged
Maxteabag merged 2 commits into
mainfrom
feat/per-connection-alerts
May 25, 2026
Merged

Maxteabag merged 2 commits into
mainfrom
feat/per-connection-alerts

Conversation

@Maxteabag

Copy link
Copy Markdown
Owner

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 delete is 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 :alert command:

  • :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 global

On the CLI — new alerts subcommand:

  • sqlit alerts list
  • sqlit alerts set <mode> [--connection NAME] [--database DB]
  • sqlit alerts unset [--connection NAME] [--database DB]

Plus --alert MODE on connections add, connections edit, and connect <provider> for setting the per-connection override at create/edit time.

Storage

  • Global stays in settings.json under query_alert_mode (unchanged).
  • Connection overrides live in ConnectionConfig.options["query_alert_mode"], so they travel with the saved connection.
  • Database overrides go in settings.json under query_alert_modes_by_database, keyed by "{connection}::{database}".

Tests

44 new tests across four files:

  • test_query_alerts_hierarchy.py — resolver + CLI handlers
  • test_alert_command_handler.py — :alert shell command (scope routing, error paths, aliases)
  • test_query_confirm_integration.py — drives the real _maybe_confirm_query to verify the wiring, not just the helper
  • existing test_query_alerts.py — unchanged, still passes

Total unit suite: 1009 passing (was 976).

Maxteabag added 2 commits May 25, 2026 15:05
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
@Maxteabag
Maxteabag merged commit 1bb6001 into main May 25, 2026
21 checks passed
@Maxteabag
Maxteabag deleted the feat/per-connection-alerts branch May 25, 2026 13:28
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.

1 participant