Skip to content

Commit

Permalink
test(csharp/test/Drivers/Snowflake): Correct FLOAT min/max tests in .…
Browse files Browse the repository at this point in the history
…NET 4.7.2 (apache#1312)

.NET 4.7.2 will round up Double.MaxValue / round down Double.MinValue
when using Double.ToString(), resulting in infinity / -infinity stored
in Snowflake when passed into the INSERT query statement. This rounding
does not occur in .NET 6.0.

This PR corrects that behavior and sends a properly accepted
MaxValue/MinValue string when using .NET 4.7.2.

Notable that when the tests can use prepared statements, issues like
this should cease to happen.
  • Loading branch information
vleslief-ms authored Nov 21, 2023
1 parent 251ce77 commit 388a1c0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions csharp/test/Drivers/Snowflake/ValueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ private static string ConvertDoubleToString(double value)
return "'-inf'";
case double.NaN:
return "'NaN'";
#if NET472
// Standard Double.ToString() calls round up the max value, resulting in Snowflake storing infinity
case double.MaxValue:
return "1.7976931348623157E+308";
case double.MinValue:
return "-1.7976931348623157E+308";
#endif
default:
return value.ToString();
}
Expand Down

0 comments on commit 388a1c0

Please sign in to comment.