Skip to content

refactor: wave 3 architecture refactoring#191

Merged
datlechin merged 7 commits intomainfrom
wave3-architecture-refactoring
Mar 7, 2026
Merged

refactor: wave 3 architecture refactoring#191
datlechin merged 7 commits intomainfrom
wave3-architecture-refactoring

Conversation

@datlechin
Copy link
Owner

Wave 3: Architecture Refactoring

Wave 1 fixed safety issues (#188). Wave 2 consolidated high-impact duplications (#189). Wave 3 tackles architectural debt: god files, extracted services, and remaining duplication.

Changes

DUP-4: Deduplicate SQL temporal function expressions

  • Added canonical temporalFunctionExpressions set + isTemporalFunction() to SQLEscaping
  • Removed duplicate 18-item sets from SQLStatementGenerator and MainContentCoordinator+SidebarSave
  • +11 tests in SQLEscapingTests

AP-6: Extract SchemaProviderRegistry from MainContentCoordinator

  • Extracted 3 static dictionaries + 5 static methods into new SchemaProviderRegistry singleton
  • Fixed architectural coupling: DatabaseManager (Core) no longer imports MainContentCoordinator (Views)
  • ContentView now uses SchemaProviderRegistry.shared directly
  • +10 tests in SchemaProviderRegistryTests

GOD-2: Split DataGridView TableViewCoordinator into extensions

  • Split 734-line TableViewCoordinator into 5 extension files:
    • DataGridView+Selection.swift — column resize/move, selection change
    • DataGridView+Editing.swift — cell editing, overlay editor, text field delegates
    • DataGridView+Columns.swift — viewFor, rowViewForRow delegates
    • DataGridView+Click.swift — click, double-click, FK arrow handlers
    • DataGridView+Sort.swift — sort descriptors, header context menu
  • DataGridView.swift: 1,344 → ~800 lines

GOD-3: Split ExportService into per-format extensions

  • Split 1,339-line ExportService into 5 per-format extension files:
    • ExportService+CSV.swift, ExportService+JSON.swift, ExportService+SQL.swift
    • ExportService+XLSX.swift, ExportService+MQL.swift
  • ExportService.swift: 1,339 → ~410 lines (shared infrastructure only)

Testing

  • 21 new tests (11 SQLEscaping + 10 SchemaProviderRegistry), all passing
  • Full build verified clean
  • Pure refactoring — no behavior changes

@chatgpt-codex-connector
Copy link

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

- Fix orphaned escapeLikeWildcards docstring placement in SQLEscaping
- Scope toUTF8Data() String extension as internal
- Keep isCancelledLock and _isCancelled private in ExportService
- Remove redundant init(forTesting:) from SchemaProviderRegistry
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Wave 3 refactor that reduces architectural coupling and file-level complexity by extracting shared services, deduplicating SQL logic, and splitting “god files” into focused extensions—while preserving behavior.

Changes:

  • Centralize SQL temporal-function detection in SQLEscaping and reuse it from statement generation + sidebar save.
  • Extract per-connection schema-provider caching into SchemaProviderRegistry (removing DatabaseManagerViews dependency).
  • Split large view/service implementations into per-concern/per-format extension files (DataGridView coordinator pieces, ExportService exporters).

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
TableProTests/Core/Services/SchemaProviderRegistryTests.swift Adds unit tests for new schema-provider registry behavior (creation, refcounting, purge/clear).
TableProTests/Core/Database/SQLEscapingTests.swift Adds coverage for SQLEscaping.isTemporalFunction behavior (case/whitespace/known functions).
TablePro/Views/Results/Extensions/DataGridView+Sort.swift Moves native sorting + header context-menu logic out of DataGridView.swift.
TablePro/Views/Results/Extensions/DataGridView+Selection.swift Moves column resize/move + selection-sync logic into a dedicated extension file.
TablePro/Views/Results/Extensions/DataGridView+Editing.swift Moves inline editing + overlay editor + text delegate handling into a dedicated extension file.
TablePro/Views/Results/Extensions/DataGridView+Columns.swift Moves view construction and row-view provisioning into a dedicated extension file.
TablePro/Views/Results/Extensions/DataGridView+Click.swift Moves click/double-click and FK navigation handlers into a dedicated extension file.
TablePro/Views/Results/DataGridView.swift Adjusts access control to support cross-file extensions; removes moved coordinator logic.
TablePro/Views/Main/MainContentCoordinator.swift Switches schema-provider caching from static storage to SchemaProviderRegistry.
TablePro/Views/Main/Extensions/MainContentCoordinator+SidebarSave.swift Replaces local temporal-function list with SQLEscaping.isTemporalFunction.
TablePro/Core/Services/SchemaProviderRegistry.swift New @MainActor registry to share/refcount SQLSchemaProvider instances with deferred cleanup.
TablePro/Core/Services/ExportService.swift Keeps shared export infrastructure; loosens access where needed for per-format extensions.
TablePro/Core/Services/ExportService+XLSX.swift Extracts XLSX export implementation into its own file.
TablePro/Core/Services/ExportService+SQL.swift Extracts SQL export implementation into its own file.
TablePro/Core/Services/ExportService+MQL.swift Extracts MongoDB/MQL export implementation into its own file.
TablePro/Core/Services/ExportService+JSON.swift Extracts JSON export implementation into its own file.
TablePro/Core/Services/ExportService+CSV.swift Extracts CSV export implementation into its own file.
TablePro/Core/Database/SQLEscaping.swift Adds canonical temporal-function set + isTemporalFunction helper.
TablePro/Core/Database/DatabaseManager.swift Updates disconnect cleanup to use SchemaProviderRegistry instead of MainContentCoordinator.
TablePro/Core/ChangeTracking/SQLStatementGenerator.swift Reuses SQLEscaping.isTemporalFunction instead of maintaining its own set.
TablePro/ContentView.swift Resolves schema provider via SchemaProviderRegistry instead of MainContentCoordinator.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@datlechin datlechin merged commit dd3a9c1 into main Mar 7, 2026
1 check passed
@datlechin datlechin deleted the wave3-architecture-refactoring branch March 7, 2026 10:39
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.

2 participants