Skip to content

feat: standardize plugin system patterns#258

Merged
datlechin merged 1 commit intomainfrom
feat/plugin-standardization-phase1
Mar 10, 2026
Merged

feat: standardize plugin system patterns#258
datlechin merged 1 commit intomainfrom
feat/plugin-standardization-phase1

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

@datlechin datlechin commented Mar 10, 2026

Summary

  • Unified error formatting: Added default errorDescription to PluginDriverError protocol, removed 10 per-driver implementations, simplified PluginDriverAdapter error handling from 9 lines to 1
  • Standardized async bridging: Migrated 25 methods across 5 queue-based drivers (MySQL, PostgreSQL, MongoDB, Redis, MSSQL) from inline withCheckedThrowingContinuation to shared pluginDispatchAsync helper with cancellation support
  • Result truncation propagation: Added isTruncated to PluginQueryResult, propagated through all 8 drivers so the UI knows when results are capped at 100K rows
  • Localization: Added String(localized:) to static error messages in MySQL, PostgreSQL, ClickHouse, Oracle, Redis, MongoDB drivers

Net: -41 lines across 21 files. All 8 driver plugins now use consistent patterns for error formatting, async bridging, and result truncation.

Test plan

  • xcodebuild build succeeds
  • xcodebuild test passes
  • Connect to each database type and verify error messages display correctly on connection failure
  • Execute a query returning >100K rows and verify truncation indicator appears in UI
  • Verify query cancellation still works for MySQL, PostgreSQL, MongoDB, Redis, MSSQL

Summary by CodeRabbit

  • Bug Fixes

    • Query result truncation is now properly reported to users instead of being silently discarded.
  • Improvements

    • Standardized error formatting across all database drivers.
    • Added localization support to database driver error messages.
    • Unified async operation handling across database drivers.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c10d7de-8268-4d64-bf2a-0286c31660f9

📥 Commits

Reviewing files that changed from the base of the PR and between 37b5cd8 and 6c43c3e.

📒 Files selected for processing (20)
  • CHANGELOG.md
  • Plugins/ClickHouseDriverPlugin/ClickHousePlugin.swift
  • Plugins/MSSQLDriverPlugin/MSSQLPlugin.swift
  • Plugins/MongoDBDriverPlugin/MongoDBConnection.swift
  • Plugins/MongoDBDriverPlugin/MongoDBPluginDriver.swift
  • Plugins/MySQLDriverPlugin/MariaDBPluginConnection.swift
  • Plugins/MySQLDriverPlugin/MySQLPluginDriver.swift
  • Plugins/OracleDriverPlugin/OracleConnection.swift
  • Plugins/OracleDriverPlugin/OraclePlugin.swift
  • Plugins/PostgreSQLDriverPlugin/LibPQPluginConnection.swift
  • Plugins/PostgreSQLDriverPlugin/PostgreSQLPluginDriver.swift
  • Plugins/PostgreSQLDriverPlugin/RedshiftPluginDriver.swift
  • Plugins/RedisDriverPlugin/RedisCommandParser.swift
  • Plugins/RedisDriverPlugin/RedisPluginConnection.swift
  • Plugins/RedisDriverPlugin/RedisPluginDriver.swift
  • Plugins/SQLiteDriverPlugin/SQLitePlugin.swift
  • Plugins/TableProPluginKit/PluginConcurrencySupport.swift
  • Plugins/TableProPluginKit/PluginDriverError.swift
  • Plugins/TableProPluginKit/PluginQueryResult.swift
  • TablePro/Core/Plugins/PluginDriverAdapter.swift

📝 Walkthrough

Walkthrough

This PR standardizes database driver plugins by adding result truncation tracking via isTruncated flag in PluginQueryResult, refactoring all driver error types to use centralized pluginErrorMessage instead of per-driver LocalizedError implementations, unifying async control flow across 5 queue-based drivers via shared pluginDispatchAsync helper, and applying consistent localization to error messages across all drivers.

Changes

Cohort / File(s) Summary
Error Type Refactoring
Plugins/.../Plugin(Connection).swift (ClickHouse, MSSQL, MySQL, Oracle, Redis, MongoDB), Plugins/TableProPluginKit/PluginDriverError.swift
Removed LocalizedError conformance and errorDescription property from all driver error types. Added pluginErrorMessage property via PluginDriverError extension. Updated static error instances (notConnected, connectionFailed, etc.) to use localized strings via String(localized:). Added centralized errorDescription builder in PluginDriverError that composes code, SQLSTATE, and error details.
Async Control Flow Unification
Plugins/MySQLDriverPlugin/MariaDBPluginConnection.swift, Plugins/PostgreSQLDriverPlugin/LibPQPluginConnection.swift, Plugins/RedisDriverPlugin/RedisPluginConnection.swift, Plugins/MongoDBDriverPlugin/MongoDBConnection.swift, Plugins/MSSQLDriverPlugin/MSSQLPlugin.swift
Replaced withCheckedThrowingContinuation patterns with centralized pluginDispatchAsync(on: queue) helper across connect, executeQuery, and executeParameterizedQuery methods. Direct error throws replace continuation resumption. New generic pluginDispatchAsync<T: Sendable> overload added to PluginConcurrencySupport with optional cancellation checking.
Result Truncation Tracking
Plugins/.../Plugin(Driver).swift (ClickHouse, MSSQL, MongoDB, MySQL, Oracle, PostgreSQL, Redshift, Redis, SQLite)
Added isTruncated: Bool field to internal query result types (CHQueryResult, FreeTDSQueryResult, etc.). Implemented truncation detection by setting flag when row count reaches PluginRowLimits.defaultMax. Propagated isTruncated through all PluginQueryResult initializations. Updated empty-result paths to explicitly set isTruncated: false.
Plugin Infrastructure Updates
Plugins/TableProPluginKit/PluginQueryResult.swift, Plugins/TableProPluginKit/PluginConcurrencySupport.swift, Plugins/TableProPluginKit/PluginDriverError.swift
Added public isTruncated: Bool property to PluginQueryResult with default false. Added new generic pluginDispatchAsync overload supporting cancellation checks and Sendable return types. Added errorDescription computed property builder in PluginDriverError extension.
Integration & Documentation
TablePro/Core/Plugins/PluginDriverAdapter.swift, CHANGELOG.md
Updated mapQueryResult to propagate pluginResult.isTruncated to QueryResult. Removed specialized PluginDriverError handling in connect error path. Added changelog entries documenting truncation reporting, unified error formatting, async bridging standardization, and localization updates.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • feat: implement plugin system #256 — Overlapping changes to the same driver plugins involving result truncation tracking, error type standardization to use PluginDriverError/pluginErrorMessage, and async control flow refactoring via shared helper mechanisms.

Poem

🐰 A rabbit's delight in organized ways,
Truncation now visible through all the days,
Errors speak many a tongue, yet one voice they share,
Async paths unified—magic in the air!

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/plugin-standardization-phase1

Comment @coderabbitai help to get the list of available commands and usage tips.

@datlechin datlechin force-pushed the feat/plugin-standardization-phase1 branch from 6ff40c1 to 6c43c3e Compare March 10, 2026 17:27
@datlechin datlechin changed the title feat: standardize plugin system patterns (Phase 1) feat: standardize plugin system patterns Mar 10, 2026
@datlechin datlechin merged commit 0085ec7 into main Mar 10, 2026
1 of 2 checks passed
@datlechin datlechin deleted the feat/plugin-standardization-phase1 branch March 10, 2026 17:29
@coderabbitai coderabbitai bot mentioned this pull request Mar 11, 2026
9 tasks
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