Skip to content

Commit

Permalink
support explicitly set scale of zero for datetime2, datetimeoffset an…
Browse files Browse the repository at this point in the history
…d time
  • Loading branch information
EamonHetherton committed Nov 8, 2021
1 parent 78e8ebc commit 0e03843
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ internal byte ScaleInternal
}
}

private bool ShouldSerializeScale() => _scale != 0; // V1.0 compat, ignore _hasScale
private bool ShouldSerializeScale() => _scale != 0 || (GetMetaTypeOnly().IsVarTime && HasFlag(SqlParameterFlags.HasScale));

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml' path='docs/members[@name="SqlParameter"]/SqlDbType/*' />
[
Expand Down Expand Up @@ -1445,8 +1445,7 @@ internal byte GetActualScale()
return ScaleInternal;
}

// issue: how could a user specify 0 as the actual scale?
if (GetMetaTypeOnly().IsVarTime)
if (GetMetaTypeOnly().IsVarTime && !HasFlag(SqlParameterFlags.HasScale))
{
return TdsEnums.DEFAULT_VARTIME_SCALE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ internal byte ScaleInternal
}
}

private bool ShouldSerializeScale() => _scale != 0; // V1.0 compat, ignore _hasScale
private bool ShouldSerializeScale() => _scale != 0 || (GetMetaTypeOnly().IsVarTime && HasFlag(SqlParameterFlags.HasScale));

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml' path='docs/members[@name="SqlParameter"]/SqlDbType/*' />
[
Expand Down Expand Up @@ -1437,8 +1437,7 @@ internal byte GetActualScale()
return ScaleInternal;
}

// issue: how could a user specify 0 as the actual scale?
if (GetMetaTypeOnly().IsVarTime)
if (GetMetaTypeOnly().IsVarTime && !HasFlag(SqlParameterFlags.HasScale))
{
return TdsEnums.DEFAULT_VARTIME_SCALE;
}
Expand Down

0 comments on commit 0e03843

Please sign in to comment.