Repository navigation
fix(core): resolve latent bugs in grid filtering, MySQL escaping, export formatters, and staging buffer disposal #698
Copy link
Copy link
Closed
Description
Description
During a deep codebase audit of Querya-Desktop, several critical and latent issues were identified across data presentation, query generation, staging buffer lifecycle, and data export.
Issues to Resolve
1. [High Severity] Row Filtering Bypassed in Grid with StagingBuffer & Mutation Index Collision
- Files:
lib/features/workspace/results_tab.dart,lib/features/workspace/result_grid_view.dart - Bug:
ResultsTabcomputesfilteredRows = _getFilteredRows(effectiveRows, ...)and passes it toVirtualResultGrid(rows: filteredRows, stagingBuffer: stagingBuffer). However,VirtualResultGrid._baseRowsdirectly returnswidget.stagingBuffer?.effectiveRows ?? widget.rows. Thus, when a staging buffer is attached (PostgreSQL, MySQL, SQLite, extensions), the filter is completely ignored visually. Furthermore, ifrowswas used directly, editing rowiof the filtered view would mutate rowiof the base buffer instead of the mapped underlying row. - Fix: Maintain an index mapping (
_filteredIndices) for grid display and route mutations through mapped original row indices.
2. [High Severity] SQL Syntax Error / Escape Issue with Backslashes in MySQL DML Generation
- Files:
lib/core/database/table_mutation_engine.dart - Bug: Strings are escaped solely by replacing
'with''. In MySQL (default SQL mode withoutNO_BACKSLASH_ESCAPES), the backslash\is an active escape character. Strings containing Windows file paths or trailing backslashes (e.g.C:\Path\) cause\'to escape the closing quote, breaking SQL syntax or leading to syntax injection vulnerabilities. - Fix: Check
SqlDialect.mysqland escape backslashes with\\prior to quoting.
3. [Medium Severity] Truncation of Leading Zeros in JSON Selection Export
- Files:
lib/features/workspace/result_grid_view.dart(ResultGridSelection.toJson) - Bug:
toJsonheuristically parses cell values usingint.tryParse(val). Strings with leading zeros (e.g."01234","007", phone numbers) are coerced to integers (1234,7), corrupting strings upon export. - Fix: Preserve strings with leading zeros (e.g.
^0\d+$) as string literals.
4. [Medium Severity] TSV Export / Copy Delimiter Corruption on Newlines & Tabs
- Files:
lib/features/workspace/result_grid_view.dart(ResultGridSelection.toTsv) - Bug: TSV export joins cells with
\tand lines with\nwithout RFC-4180 style quoting. Cells with internal newlines or tabs break column and row alignments when pasted into spreadsheet applications. - Fix: Quote cells containing
\t,\n, or"using standard TSV/CSV quoting rules.
5. [Medium Severity] StagingBuffer Memory Leak in SqlQueryTabSession
- Files:
lib/features/workspace/sql_query_tab_session.dart - Bug:
SqlQueryTabSession.dispose()disposescontrollerandtopFraction, but fails to callstagingBuffer?.dispose(). Attached listeners and buffer data remain in memory when tabs are closed. - Fix: Ensure
stagingBuffer?.dispose()is invoked indispose().
Acceptance Criteria
- Row filtering works correctly even when a
StagingBufferis attached. - Edits in filtered view accurately mutate the target row in the underlying buffer.
- MySQL DML generation properly handles backslashes (
\). - JSON export preserves strings with leading zeros.
- TSV export properly escapes cells with newlines and tabs.
-
SqlQueryTabSession.dispose()cleanly disposesstagingBuffer. - All unit and widget tests pass.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
ZhuchkaTriplesix commentedon Sep 6, 2026
Resolved and merged into main via PR #699 and Release 0.4.15 (PR #705).