Skip to content

sec(extensions): add destructive SQL confirmation modal to ExtensionSqlWorkspace #638

Description

@ZhuchkaTriplesix

Motivation & Problem

In #608, a confirmation dialog was implemented for destructive DDL and DML operations (DROP TABLE, DROP DATABASE, TRUNCATE, DELETE without WHERE) via DestructiveSqlDetector.inspect(userSql) and showDestructiveQueryDialog. This guard was integrated into PostgresSqlWorkspace, MysqlSqlWorkspace, and SqliteSqlWorkspace.

However, ExtensionSqlWorkspace (lib/features/extensions/extension_sql_workspace.dart) was omitted. When running queries against extension-backed databases (such as ClickHouse or future custom driver extensions), destructive operations like DROP TABLE analytics.events are executed immediately without user confirmation, bypassing the AppSettings.confirmDestructiveOperations safety setting.

Proposed Scope

  1. In ExtensionSqlWorkspace._execute():
    • Check AppSettings.instance.getConfirmDestructiveOperations().
    • Inspect the SQL query using DestructiveSqlDetector.inspect(userSql).
    • If destructive, present showDestructiveQueryDialog with the connection name and target object details.
    • Proceed with ExtensionDriverSession.instance.query(...) only if confirmed.
  2. Add widget tests verifying that destructive queries in ExtensionSqlWorkspace prompt for confirmation and can be aborted or confirmed.

Acceptance Criteria

  • Executing DROP TABLE, DROP DATABASE, or TRUNCATE in ExtensionSqlWorkspace triggers showDestructiveQueryDialog when confirmation is enabled.
  • Clicking "Cancel" or pressing Escape aborts execution without sending the query to the driver.
  • If AppSettings.confirmDestructiveOperations is disabled, queries execute without prompting.
  • Unit and widget tests verify the confirmation flow in ExtensionSqlWorkspace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    editorCode/SQL editorstabilityTheme parser epic label: stabilityuiUser interface components and widgets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions