Repository navigation
Conversation
…tValues - GetOrdinal throws IndexOutOfRangeException for an unknown name, as IDataRecord.GetOrdinal documents, instead of ArgumentOutOfRangeException - GetValues copies only as many values as the array holds and returns that count, as IDataRecord.GetValues documents, instead of throwing for an array shorter than the row Fixes dotnet#39343 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 21, 2026
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
Summary
Two
SqliteDataReadermembers depart from the documentedIDataRecordcontract:GetOrdinalfor an unknown name throwsArgumentOutOfRangeException. IDataRecord.GetOrdinal: "If the index of the named field is not found, anIndexOutOfRangeExceptionis thrown." It now throwsIndexOutOfRangeExceptionwith the name as the message, as SqlClient does. The exact-match lookup, the case-insensitive fallback and the ambiguous-nameInvalidOperationExceptionare unchanged.GetValuesthrows when the array is shorter than the row. IDataRecord.GetValues: "You can pass an Object array that contains fewer than the number of columns that are contained in the resulting row. Only the amount of data the Object array holds is copied to the array." It now copiesMath.Min(values.Length, FieldCount)values and returns that count.Tests
GetOrdinal_throws_when_out_of_rangenow expectsIndexOutOfRangeException.GetValues_throws_when_too_narrowis replaced byGetValues_copies_only_what_fits_when_too_narrow: a 2-element array for a 3-column row, and an empty array.Microsoft.Data.Sqlite.Tests: 784 passed, 0 failed (7 skipped).Behaviour change: code catching
ArgumentOutOfRangeExceptionfromGetOrdinalneeds to catchIndexOutOfRangeException.Checklist
Found by the pengdows ADO.NET conformance suite, which runs the documented
System.Data.Commoncontract against every provider. These two are the only Required tests Microsoft.Data.Sqlite 9.0.5 fails there.🤖 Generated with Claude Code