Skip to content

Commit

Permalink
fix null binary rowversion and add test coverage (dotnet#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 authored and DavoudEshtehari committed Aug 11, 2022
1 parent 7cf5286 commit 27d3746
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,10 @@ internal SqlBinary SqlBinary
{
if (StorageType.SqlBinary == _type)
{
if (IsNull)
{
return SqlBinary.Null;
}
return (SqlBinary)_object;
}
return (SqlBinary)SqlValue; // anything else we haven't thought of goes through boxing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ public static void CheckNullRowVersionIsBDNull()
Assert.IsType<DBNull>(result);
Assert.Equal(result, reader.GetFieldValue<DBNull>(0));
Assert.Throws<SqlNullValueException>(() => reader.GetFieldValue<byte[]>(0));

SqlBinary binary = reader.GetSqlBinary(0);
Assert.True(binary.IsNull);

SqlBytes bytes = reader.GetSqlBytes(0);
Assert.True(bytes.IsNull);
Assert.Null(bytes.Buffer);

}
finally
{
Expand Down

0 comments on commit 27d3746

Please sign in to comment.