Repository navigation
fix(sqlite): columns with the same name stay separate in query results (#1144) - #1243
Merged
Merged
Conversation
#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.
Grid scroll benchmark
Informational only (threshold 5%). Shared CI runners are noisy; re-run before trusting a single result. |
3 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1144
Problem
SQLite query results were read as maps keyed by column name, so
SELECT o.id, u.idshowed one column with the wrong value. The same happened toSELECT 1, 1,o.*, u.*and the table browser's custom SQL.Change
sqliteUniqueColumnsSql(insqlite_sql.dart) wraps a singleSELECTorWITHstatement inSELECT * FROM (...). SQLite then names the repeatsidandid:1.SqliteSqlExecutionDelegate.executeQuery) apply it before the LIMIT is injected, so the LIMIT stays on the outer query.loadCustomSql) applies it too.Behaviour to know about
The repeated columns are shown as
idandid:1, which is how SQLite names them inside a subquery. Earlier, the repeat was lost entirely.sqflitedoes 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:McpQueryService:o.id, u.id,SELECT 1, 1,o.*, u.*, a WITH query, and unique names keeping their order.