Skip to content

manage TDS_DATA_COLUMNSTATUS in ValueReader #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/AdoNetCore.AseClient/Enum/TdsDataColumnStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
// ReSharper disable InconsistentNaming

namespace AdoNetCore.AseClient.Enum
{
[Flags]
internal enum TdsDataColumnStatus : byte
{
/// <summary>
/// No Data follows, the value is NULL.
/// </summary>
TDS_DATA_COLUMNSTATUS_NO_DATA = 0x01,
/// <summary>
/// This data value is corrupted due to Overflow/Underflow.
/// </summary>
TDS_DATA_COLUMNSTATUS_CORRUPTED = 0x02,
/// <summary>
/// This data value has been truncated or rounded.
/// </summary>
TDS_DATA_COLUMNSTATUS_TRUNCATED = 0x04,
}
}
9 changes: 9 additions & 0 deletions src/AdoNetCore.AseClient/Internal/ValueReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ private static object ReadInternal(Stream stream, FormatItem format, DbEnvironme
{
if (ReadMap.ContainsKey(format.DataType))
{
// If the TDS_DATA_COLUMNSTATUS request capability is enabled, then all datatype representations begin with a status byte
if (format.RowStatus.HasFlag(RowFormatItemStatus.TDS_ROW_COLUMNSTATUS))
{
var columnStatus = (TdsDataColumnStatus)stream.ReadByte();
if (columnStatus.HasFlag(TdsDataColumnStatus.TDS_DATA_COLUMNSTATUS_NO_DATA))
{
return DBNull.Value;
}
}
return ReadMap[format.DataType](stream, format, env) ?? DBNull.Value;
}

Expand Down