Skip to content

refactor(workspace): extract SqlWorkspaceToolbar and introduce BaseSqlExecutionDelegate #1363

Closed

Description

@ZhuchkaTriplesix

Summary

  1. lib/features/workspace/generic_sql_workspace.dart is 1,546 lines long and combines:
    • A complex 350+ line toolbar with 10+ controls (Execute, Explain, Cancel, session options, autocommit, timeouts).
    • Session lifecycle and tab management.
    • DML preview dialogs, destructive query guards, and staged save flows.
  2. Across postgres_sql_workspace.dart, mysql_sql_workspace.dart, and sqlite_sql_workspace.dart, the SQL execution delegates repeat boilerplate logic:
    • injectSqlLimit and truncated row checks.
    • Autocommit check with automatic BEGIN transaction initiation.
    • Status message formatting (Showing first $cap row(s)... , Command completed., $n row(s).).

This redundancy complicates maintenance and conflicts with single-responsibility design (related to Epic #1151).

Proposed Solution

  1. Extract the toolbar into lib/features/workspace/sql_workspace_toolbar.dart.
  2. Introduce an abstract BaseSqlExecutionDelegate in lib/features/workspace/sql_execution_delegate.dart that centralizes limit injection, transaction handling, and status message resolution.
  3. Have PostgreSQL, MySQL, and SQLite delegates extend BaseSqlExecutionDelegate and implement only driver-specific socket execution.

Acceptance Criteria

  • GenericSqlWorkspace delegates toolbar rendering to SqlWorkspaceToolbar.
  • Common execution boilerplate (limit injection, transaction state check, status line) is shared via BaseSqlExecutionDelegate.
  • All database workspace unit and widget tests pass.

Activity

  1. added
    editorCode/SQL editor
    frontendTheme parser epic label: frontend
    backendBackend database driver execution and queries
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1392 (merged into dev).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringbackendBackend database driver execution and querieseditorCode/SQL editorfrontendTheme parser epic label: frontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions