Problem Statement
1. Critical Index Desync in VirtualResultGrid during Active Sorting (Data Corruption Risk)
In VirtualResultGrid (lib/features/workspace/result_grid_view.dart), sortResultGridRows reorders rows in memory but discards the original model indices. When a user interacts with a sorted grid:
- Edits committed via stagingBuffer.setCell(row, column, value) pass the visual rowIndex rather than the underlying model index, corrupting unrelated rows.
- Staged row and cell statuses (getRowStatus, getCellStatus, isCellModified, isRowDeleted) query by visual index, misrepresenting modified/deleted rows.
- Row operations (duplicateRow, toggleDeleteRow, setNull, revertRow) mutate the wrong rows in the staging buffer.
2. Missing Column Sorting in Database Table Views
In SqliteTableView, PostgresTableView, and MysqlTableView, table headers are non-interactive plain Text widgets:
- Clicking column headers does nothing (no sort event, no direction indicator).
- _browseDataSql() queries execute without ORDER BY, preventing server-side sorting across pagination boundaries.
Proposed Solution
-
Model Index Mapping in VirtualResultGrid:
- Maintain _sortedToModelIndices mapping visualRowIndex -> modelRowIndex.
- Forward modelRowIndex to stagingBuffer operations, row selection callbacks, and cell status evaluators.
- Retain visual row indices strictly for rendering, virtualization, and keyboard navigation.
-
Server-Side Interactive Sorting in Table Views:
- Introduce _sortColumn and _sortAscending state in SqliteTableView, PostgresTableView, and MysqlTableView.
- Update _headerCell to render clickable sort headers with direction indicators (arrow_upward, arrow_downward) cycling ASC -> DESC -> none.
- Parameterize _browseDataSql() with ORDER BY <quoted_column> ASC/DESC.
- Re-fetch data upon sort changes with reset to page 0.
-
Comprehensive Tests:
- Unit tests verifying model index preservation and staging mutations during active sorting.
- Widget tests for header click sorting and SQL generation in table views.
Reactions are currently unavailable
Problem Statement
1. Critical Index Desync in VirtualResultGrid during Active Sorting (Data Corruption Risk)
In VirtualResultGrid (lib/features/workspace/result_grid_view.dart), sortResultGridRows reorders rows in memory but discards the original model indices. When a user interacts with a sorted grid:
2. Missing Column Sorting in Database Table Views
In SqliteTableView, PostgresTableView, and MysqlTableView, table headers are non-interactive plain Text widgets:
Proposed Solution
Model Index Mapping in VirtualResultGrid:
Server-Side Interactive Sorting in Table Views:
Comprehensive Tests: