Repository navigation
GetValues copies only what the array holds - #376
Conversation
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." A shorter array threw IndexOutOfRangeException. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 39416786400Warning 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.553%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
|
Thanks, the fix looks right. I compared it with Npgsql 10.0.0 against PostgreSQL 18.3 on One more difference, though: public override int GetValues(object[] values)
{
ArgumentNullException.ThrowIfNull(values);
CheckRowRead();
...And two small things for the test:
|
|
The requested null check and empty-array coverage are already committed, including the null ArgumentNullException assertion. Thanks for the review. |
DuckDBDataReader.GetValues(object[])writesFieldCountvalues whatever the array's length, so an array shorter than the row throwsIndexOutOfRangeException.The contract
IDataRecord.GetValues, Remarks:
Change
Copy
Math.Min(values.Length, FieldCount)values and return that count. A longer array was already handled. The new test checks both cases (GetValuesCopiesOnlyWhatTheArrayHolds), and the full suite passes.Conformance test:
GetValues_copies_only_what_fits_when_the_array_is_shorter.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