Repository navigation
Throw IndexOutOfRangeException from SqliteDataReader.GetOrdinal for an unknown name - #39353
Merged
AndriySvyryd merged 1 commit intoOct 22, 2026
Merged
Conversation
…n unknown name GetOrdinal threw ArgumentOutOfRangeException when no column matched. IDataRecord.GetOrdinal: "If the index of the named field is not found, an IndexOutOfRangeException is thrown." The exact-match lookup, the case-insensitive fallback and the ambiguous-name InvalidOperationException are unchanged. Fixes dotnet#39343 Found with https://github.com/pengdows/pengdows.AdoNetApiTest.conformance Co-Authored-By: Claude Opus 5.5 <[email protected]>
5 of 6 tasks
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The documented exception behavior is implemented and covered by tests; only a minor assertion-strengthening nit remains.
No open issues 🎉
What changed in this PR
This pull request updates SqliteDataReader.GetOrdinal to throw the documented IndexOutOfRangeException when a requested column name is not found.
Changes:
- Replaces
ArgumentOutOfRangeExceptionwithIndexOutOfRangeException. - Preserves the requested column name as the exception message.
- Updates regression coverage for the exception contract.
| File | Description |
|---|---|
test/Microsoft.Data.Sqlite.Tests/SqliteDataReaderTest.cs |
Verifies the new exception type and message; an exact message assertion is recommended as a minor nit. |
src/Microsoft.Data.Sqlite.Core/SqliteDataRecord.cs |
Implements the corrected exception behavior for unknown column names. |
Review effort: Lite
AndriySvyryd
approved these changes
Oct 22, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
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 #39343
SqliteDataReader.GetOrdinalthrowsArgumentOutOfRangeExceptionfor a name that matches no column; it now throwsIndexOutOfRangeExceptionwith the name as the message. The exact-match lookup, the case-insensitive fallback and the ambiguous-nameInvalidOperationExceptionare unchanged.What the documentation says
IDataRecord.GetOrdinal, Remarks:
Why this is a bug
The exception type is the documented contract.
ArgumentOutOfRangeExceptionis anArgumentException, not anIndexOutOfRangeException, socatch (IndexOutOfRangeException)around an optional-column probe does not catch it.Tests
GetOrdinal_throws_when_out_of_rangenow expectsIndexOutOfRangeExceptionwith the name in the message.Microsoft.Data.Sqlite.Tests: 784 passed, 0 failed (7 skipped).Behaviour change: code catching
ArgumentOutOfRangeExceptionfromGetOrdinalneeds to catchIndexOutOfRangeException.This is the
GetOrdinalhalf of #39344, which I'm closing in favour of one PR per change; theGetValueshalf is #39352 / its own PR.Checklist
Found with https://github.com/pengdows/pengdows.AdoNetApiTest.conformance
🤖 Generated with Claude Code