Skip to content

Commit

Permalink
[Fix] Fix null binary rowversion and add test coverage
Browse files Browse the repository at this point in the history
Porting dotnet#1688 to 3.1-servicing.
  • Loading branch information
David-Engel committed Aug 9, 2022
1 parent db1c825 commit 7103626
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,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 @@ -490,6 +490,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 7103626

Please sign in to comment.