Repository navigation
Skip indexes on expressions when reverse engineering SQLite - #39577
Merged
cincuranet merged 2 commits intoNov 10, 2026
Merged
cincuranet merged 2 commits into
cincuranet merged 2 commits into
Conversation
pragma_index_xinfo returns a NULL column name for a key that is an expression (for example CREATE INDEX IX ON T (lower(Name))), and the SQLite database model factory called GetString on it, so scaffolding failed with an InvalidOperationException. Indexes on expressions can't be represented in the model, so skip them and log a warning (SqliteEventId.ExpressionIndexSkippedWarning) instead. Fixes dotnet#39573 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cover an expression index between regular indexes (so skipping must not stop processing the table), tables with only expression indexes including a unique one and an unusual name, and an expression index next to a unique constraint. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cincuranet
approved these changes
Nov 10, 2026
Contributor
API review baseline changes for
|
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.
Fixes #39573
Problem
Reverse engineering a SQLite database with an index on an expression, for example
CREATE INDEX IX ON T (lower(Name)), threwInvalidOperationException: The data is NULL at ordinal 0.pragma_index_xinforeturns a NULLname(withcid = -2) for a key that is an expression, andSqliteDatabaseModelFactory.GetIndexescalledGetString(0)on it.Fix
GetIndexesnow skips any index that has an expression key, including indexes that mix columns and expressions, and logs a warning. Indexes on expressions can't be represented in the model (#28360). The rest of the table, including its other indexes, is scaffolded as usual.The warning is a new scaffolding event,
SqliteEventId.ExpressionIndexSkippedWarning, registered the same way as the existingFormatWarningandOutOfRangeWarningevents (event id, logging definition, resource string, logger extension and API baseline entry):No other code path needs the change:
NULLnames only occur for expression keys, and SQLite does not allow expressions inUNIQUEorPRIMARY KEYconstraints, so the unique-constraint and primary-key readers can't hit this.Tests
New
SqliteDatabaseModelFactoryTesttests cover an expression index next to a regular index, an expression index between two regular indexes (so skipping can't stop processing the table), a mixed column-and-expression index, tables with only expression indexes (including a unique one and an unusual name, one warning each), and an expression index alongside a unique constraint.🤖 Generated with Claude Code