You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Microsoft.Data.Sqlite: GetValues rejects an array shorter than the row, unlike the IDataRecord contract #39352
SqliteDataReader.GetValues throws when the array is shorter than the row, where the IDataRecord contract says it copies what fits. (Split out of #39343 so each change can be reviewed on its own.)
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.
Why this is a bug
The contract explicitly allows a short array and says what happens: the first values.Length columns are copied and that count is returned. Microsoft.Data.Sqlite throws IndexOutOfRangeException instead, so code that reads only the leading columns of a wide row into a fixed-size buffer (valid against SqlClient, Npgsql and MySqlConnector) fails here.
The current behaviour is pinned by GetValues_throws_when_too_narrow. I have a small change that follows the documented contract (copy Math.Min(values.Length, FieldCount) values and return that count) and replaces that test; I'll link it here.
Activity
Copy only what fits in SqliteDataReader.GetValues (dotnet#39354)