Skip to content

Commit eb04d40

Browse files
authored
Limited decimal precision to max supported
1 parent b75cfc7 commit eb04d40

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/SqlClient.Tests/TypeProviderTest.fs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ let ``Roundtrip ToTraceString for unicode``() =
140140

141141
[<Fact>]
142142
let ``Roundtrip ToTraceString for decimals with maximum precision``() =
143-
let cmd = new SqlCommandProvider<"SELECT CAST(@x AS DECIMAL(38, 18))", ConnectionStrings.AdventureWorksNamed>()
144-
let decimal_38_18 = 12345678901234567890.123456789012345678m
145-
let result = runScalarQuery <| cmd.ToTraceString(decimal_38_18)
146-
Assert.Equal(expected = decimal_38_18, actual = unbox<decimal> result)
143+
// Note: maximum precision for MSSQL decimals is 38, but maximum for MSSQL <-> .NET conversion is 29
144+
// https://weblogs.sqlteam.com/mladenp/2010/08/31/when-does-sql-server-decimal-not-convert-to-net-decimal/
145+
let cmd = new SqlCommandProvider<"SELECT CAST(@x AS DECIMAL(29, 19))", ConnectionStrings.AdventureWorksNamed>()
146+
let decimal_29_19 = 1234567890.1234567890123456789m
147+
let result = runScalarQuery <| cmd.ToTraceString(decimal_29_19)
148+
Assert.Equal(expected = decimal_29_19, actual = unbox<decimal> result)
147149

148150
[<Fact>]
149151
let ``Roundtrip ToTraceString for date time ``() =

0 commit comments

Comments
 (0)