This PR resolves two major sorting issues (closing #696):
Critical Data Grid Sorting Index Desync Fix: In VirtualResultGrid, in-memory sorting now preserves original model indices via _sortedToModelIndices. Staging buffer edits, deletions, and status checks now target the correct model row rather than the visual row index, eliminating silent data corruption during active sorting.
Interactive Server-Side Sorting in Table Views: Added interactive column headers with sort direction indicators (ASC / DESC) and safe quoted ORDER BY SQL generation to SqliteTableView, PostgresTableView, and MysqlTableView.
Implemented sortResultGridRowsWithIndices returning SortedResultGridData with both sorted rows and sortedToModelIndices.
Maintained backward compatibility for sortResultGridRows.
Added _toModelRowIndex(visualRow) mapping in _VirtualResultGridState.
Forwarded modelRowIndex to _DataRow for stagingBuffer.getRowStatus, stagingBuffer.getCellStatus, setCell, setCellNull, revertCell, toggleDeleteRow, and revertRow.
Added interactive header sorting and parameterized _browseDataSql() with quoteMysqlIdentifier.
Automated Tests:
test/features/workspace/result_grid_sorting_model_test.dart: Unit tests for index mapping and widget tests confirming staging mutations target the correct model row under active sorting.
test/features/workspace/table_view_sorting_test.dart: Unit tests for SQL generation across SQLite, PostgreSQL, and MySQL, plus widget tests for header interaction.
Verification
flutter analyze: 0 issues found.
All workspace and database test suites passed (425+ tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR resolves two major sorting issues (closing #696):
Key Changes
Verification
Closes #696