Repository navigation
GetOrdinal: case-insensitive fallback and IndexOutOfRangeException - #375
Merged
Merged
Conversation
IDataRecord.GetOrdinal: "GetOrdinal performs a case-sensitive lookup first. If it fails, a second case-insensitive search is made. GetOrdinal is kana-width insensitive. If the index of the named field is not found, an IndexOutOfRangeException is thrown." Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 39416608021Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.07%) to 92.561%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
This branch is waiting to be deployed
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.
DuckDBDataReader.GetOrdinalonly finds an exact, case-sensitive match. For a name that isn't found it throwsDuckDBException.The contract
IDataRecord.GetOrdinal, Remarks:
Why it matters
DuckDB folds unquoted identifiers, so
SELECT id FROM tandreader.GetOrdinal("Id")refer to the same column, yet the second call throws. Mappers (Dapper, hand-writtenreader["Name"]code) that work against SqlClient, Npgsql, MySqlConnector and Microsoft.Data.Sqlite fail on DuckDB because of how a property happens to be capitalised. Code that catchesIndexOutOfRangeExceptionto test for an optional column, as the contract allows, gets aDuckDBExceptioninstead.Change
columnMappingis still tried first, so a column whose name matches exactly always wins (SELECT 1 AS Id, 2 AS idkeeps returning 0 for"Id"and 1 for"id").CompareOptions.IgnoreCase | IgnoreKanaType | IgnoreWidth, which is what "case-insensitive … kana-width insensitive" describes.IndexOutOfRangeException.Behaviour change: callers that catch
DuckDBExceptionfromGetOrdinalneed to catchIndexOutOfRangeException. The two tests that pinned the old type (GetOrdinalReturnsColumnIndex,GetOrdinalRepeatedColumnReturnsFirstIndex) now expect the documented one.New tests:
GetOrdinalFallsBackToACaseInsensitiveMatch(exact match wins, case and width folding) andGetOrdinalThrowsIndexOutOfRangeForAnUnknownName. The full suite passes.Conformance tests:
GetOrdinal_works,GetOrdinal_throws_when_out_of_range.Found by the pengdows ADO.NET conformance suite, which runs the documented
System.Data.Commoncontract against every provider; each failure it reports cites the learn.microsoft.com sentence the provider departs from.🤖 Generated with Claude Code