Skip to content

fix(sqlite): columns with the same name stay separate in query results (#1144) - #1243

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
fix/1144-sqlite-duplicate-columns
Oct 9, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
fix/1144-sqlite-duplicate-columns

Conversation

@ZhuchkaTriplesix

@ZhuchkaTriplesix ZhuchkaTriplesix commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Closes #1144

Problem

SQLite query results were read as maps keyed by column name, so SELECT o.id, u.id showed one column with the wrong value. The same happened to SELECT 1, 1, o.*, u.* and the table browser's custom SQL.

Change

  • sqliteUniqueColumnsSql (in sqlite_sql.dart) wraps a single SELECT or WITH statement in SELECT * FROM (...). SQLite then names the repeats id and id:1.
  • The SQL editor and MCP path (SqliteSqlExecutionDelegate.executeQuery) apply it before the LIMIT is injected, so the LIMIT stays on the outer query.
  • The table browser's custom SQL (loadCustomSql) applies it too.
  • Other statements, several statements at once, and results with unique names are unchanged.

Behaviour to know about

The repeated columns are shown as id and id:1, which is how SQLite names them inside a subquery. Earlier, the repeat was lost entirely. sqflite does not expose the column list positionally, so this is the approach that keeps every column without a driver change.

Tests

test/core/database/sqlite_unique_columns_test.dart:

  • unit cases for the wrapper (WITH, trailing comments and semicolons, statements left unchanged);
  • regression on a real SQLite file through McpQueryService: o.id, u.id, SELECT 1, 1, o.*, u.*, a WITH query, and unique names keeping their order.

#1144)

rawQuery returns rows as maps keyed by column name, so SELECT o.id, u.id
collapsed into one column with the wrong value. Read-only SELECT and WITH
statements are now wrapped in SELECT * FROM (...), which makes SQLite name
the repeats id and id:1. The table browser's custom SQL and the SQL editor
and MCP paths share the wrapper. Unique names and other statements are
unchanged.
@github-actions github-actions Bot added bug Something isn't working sqlite SQLite database driver and workspace data-grid Interactive data grid, cell editor, filtering, groupings P1 High priority / Core capability labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Grid scroll benchmark

metric base PR change
p50 16.86 ms 17.01 ms +0.9%
p90 23.41 ms 25.03 ms +6.9% ⚠️
p99 51.45 ms 53.14 ms +3.3%
stutters 290.00 267.00 -7.9%

Informational only (threshold 5%). Shared CI runners are noisy; re-run before trusting a single result.

@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 855705f into dev Oct 9, 2026
15 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the fix/1144-sqlite-duplicate-columns branch October 11, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working data-grid Interactive data grid, cell editor, filtering, groupings P1 High priority / Core capability sqlite SQLite database driver and workspace

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant