Skip to content

feat: add table export functionality#13

Merged
datlechin merged 35 commits intomainfrom
feat/export-tables
Dec 29, 2025
Merged

feat: add table export functionality#13
datlechin merged 35 commits intomainfrom
feat/export-tables

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • Add comprehensive table export feature supporting CSV, JSON, and SQL formats
  • Export dialog with table selection tree (supports multi-database, multi-table selection)
  • Real-time progress tracking with row counts and cancellation support
  • Success dialog with quick access to exported file location

Features

  • CSV Export: Configurable delimiter, quote handling, line breaks, decimal format
  • JSON Export: Pretty print option, null value handling
  • SQL Export: Structure, data, drop statements, gzip compression
  • Progress Dialog: Shows table name, row progress (e.g., "95,500/175,787 rows"), progress bar, stop button
  • Success Dialog: "Open containing folder" button, "Don't show this again" checkbox
  • Context Menu: Export option in sidebar (right-click on tables or empty space)
  • Keyboard Shortcut: ⌘⇧E to open export dialog

Performance

  • Throttled progress updates (every 1000 rows) to prevent UI freezing on large tables
  • Background thread compression and file writing
  • Efficient file-to-file gzip compression

Test plan

  • Export single table to CSV, verify format options work
  • Export single table to JSON, verify pretty print and null handling
  • Export single table to SQL, verify structure/data/drop options
  • Export multiple tables, verify progress shows correct table count
  • Export large table (100k+ rows), verify progress updates smoothly
  • Export with gzip compression, verify file is compressed
  • Test "Stop" button during export
  • Test "Open containing folder" in success dialog
  • Test "Don't show this again" preference persists
  • Test export from context menu (on table and empty space)
  • Test ⌘⇧E keyboard shortcut

- Add ExportDialog with table selection tree and format options
- Support CSV export with configurable delimiter, quoting, line breaks
- Support JSON export with pretty print and null value options
- Support SQL export with structure, data, drop statements, and gzip compression
- Add real-time progress dialog with row count and cancellation support
- Add success dialog with "Open containing folder" and "Don't show this again" options
- Add Export option to sidebar context menu and Database menu (⌘⇧E)
- Optimize export for large tables with throttled progress updates
- Run compression and file writes on background threads
Copilot AI review requested due to automatic review settings December 28, 2025 12:54
Copy link
Copy Markdown

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

This PR adds comprehensive table export functionality to TablePro, enabling users to export database tables to CSV, JSON, and SQL formats. The feature includes a sophisticated UI with table selection trees, format-specific options, real-time progress tracking, and keyboard shortcuts for improved workflow efficiency.

Key changes:

  • Export service layer with format-specific logic for CSV, JSON, and SQL exports
  • Dialog-based UI with table selection tree supporting multi-database/schema selection
  • Progress tracking with throttled updates and cancellation support
  • Success dialog with "Don't show again" preference and quick folder access

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
TablePro/Views/Sidebar/SidebarView.swift Adds "Export..." context menu options and ⌘⇧E keyboard shortcuts
TablePro/Views/MainContentView.swift Passes table data to alert handler for export dialog
TablePro/Views/Main/MainContentNotificationHandler.swift Handles exportTables notification to trigger dialog
TablePro/Views/Main/MainContentCoordinator.swift Adds showExportDialog published state
TablePro/Views/Main/Child/MainContentAlerts.swift Presents export dialog sheet with preselected tables
TablePro/Views/Main/Child/QueryTabContentView.swift Adds onDismissError callback parameter
TablePro/Views/Export/ExportDialog.swift Main export dialog with format selection, options, and save logic
TablePro/Views/Export/ExportTableTreeView.swift Tree view for selecting tables with SQL-specific checkboxes
TablePro/Views/Export/ExportProgressView.swift Progress dialog showing current table and row counts
TablePro/Views/Export/ExportSuccessView.swift Success dialog with folder access and preference toggle
TablePro/Views/Export/ExportCSVOptionsView.swift CSV format options (delimiter, quoting, line breaks, etc.)
TablePro/Views/Export/ExportJSONOptionsView.swift JSON format options (pretty print, null handling)
TablePro/Views/Export/ExportSQLOptionsView.swift SQL format options (gzip compression)
TablePro/Models/ExportModels.swift Data models for export configuration and options
TablePro/Core/Services/ExportService.swift Core export logic with progress tracking and format handlers
TablePro/TableProApp.swift Adds "Export..." menu item with keyboard shortcut

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

Comment thread TablePro/Views/Sidebar/SidebarView.swift Outdated
Comment thread TablePro/Views/Export/ExportDialog.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Views/Export/ExportCSVOptionsView.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Views/Export/ExportDialog.swift
datlechin and others added 7 commits December 28, 2025 20:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Remove duplicate keyboard shortcuts from context menus (keep only in main menu)
- Fix SQL injection in schema/database queries by escaping single quotes
- Optimize memory usage: stream CSV/SQL exports directly to file instead of building in memory
- Use file-to-file gzip compression for better performance
- Combine tableContextMenu(for:) and sidebarContextMenu() into tableContextMenu(clickedTable:)
- All menu items always visible with disabled state when no selection
- Smart behavior: clicking table row without selection uses that table
- Cleaner, more maintainable single source of truth
- Remove unused Compression import
- Replace force unwraps with safe toUTF8Data() helper that throws on failure
- Add proper error handling for file creation with guard statements
- Stream JSON export directly to file instead of building in memory
- Add escapeJSONString() and formatJSONValue() helpers for proper JSON formatting
Copy link
Copy Markdown

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

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


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

Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Views/Sidebar/SidebarView.swift
Comment thread TablePro/Views/Export/ExportSuccessView.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
datlechin and others added 7 commits December 28, 2025 21:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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

Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.


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

Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Views/Export/ExportDialog.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Views/Sidebar/SidebarView.swift
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Views/Export/ExportTableTreeView.swift
datlechin and others added 4 commits December 29, 2025 09:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 14 comments.


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

Comment thread TablePro/Views/Export/ExportSQLOptionsView.swift
Comment thread TablePro/Views/Export/ExportDialog.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Database/MySQLDriver.swift Outdated
Comment thread TablePro/Views/Export/ExportDialog.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Views/Sidebar/SidebarView.swift
Comment thread TablePro/Core/Database/SQLEscaping.swift
datlechin and others added 3 commits December 29, 2025 09:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 8 comments.


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

Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Views/Export/ExportDialog.swift Outdated
Comment thread TablePro/Views/Export/ExportDialog.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
datlechin and others added 4 commits December 29, 2025 09:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 13 comments.


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

Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Views/Export/ExportDialog.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Views/Export/ExportDialog.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Views/Sidebar/SidebarView.swift
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Database/MySQLDriver.swift
datlechin and others added 8 commits December 29, 2025 10:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.


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

Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift Outdated
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Core/Services/ExportService.swift
Comment thread TablePro/Views/Export/ExportDialog.swift
@datlechin datlechin merged commit 4402baa into main Dec 29, 2025
@datlechin datlechin deleted the feat/export-tables branch December 29, 2025 03:22
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