Skip to content

.NET 11 change leads to invalid decimal values read from database #240

Open

Description

@MaceWindu

Breaking change note from MS
https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/11/decimal-biginteger-floating-point-conversions

Describe the bug

On .NET 11, every AseDataReader read path returns DECIMAL / NUMERIC values with ~28 digits of floating-point noise.

To Reproduce

using AdoNetCore.AseClient;

using var cn = new AseConnection("...");
cn.Open();

using var cmd = cn.CreateCommand();
cmd.CommandText = "SELECT CAST(123.45 AS DECIMAL(10,2))";

using var rd = cmd.ExecuteReader();
rd.Read();

Console.WriteLine(rd.GetValue(0));    // boxed decimal
Console.WriteLine(rd.GetDecimal(0));
Console.WriteLine(rd.GetString(0));
Console.WriteLine(rd.GetDouble(0));

CAST(123.45 AS DECIMAL(10,2)):

read path .NET 10.0.12 .NET 11.0.0
GetValue 123.45 123.45000000000000256981935710
indexer rd[0] 123.45 123.45000000000000256981935710
GetProviderSpecificValue 123.45 123.45000000000000256981935710
GetDecimal 123.45 123.45000000000000256981935710
GetString 123.45 123.45000000000000256981935710
GetDouble 123.45 123.45
GetFieldType System.Decimal System.Decimal

CAST(12.34 AS MONEY) is exact on both runtimes across every path, so whatever the MONEY path does is unaffected.

Wider values lose real precision rather than just gaining noise — CAST(12345678901234.5678 AS NUMERIC(38,10)):

read path .NET 10.0.12 .NET 11.0.0
GetDecimal 12345678901234.5678 12345678901234.568391626365046
GetDouble 12345678901234.568 12345678901234.568

So on .NET 10 the DECIMAL/NUMERIC path carries more than double precision, and on .NET 11 the digits past double precision are gone from every path — a consumer cannot recover them.

Environment

  • AdoNetCore.AseClient 0.19.2
  • SAP ASE 16.1
  • Windows 10, x64
  • .NET 10.0.12 and .NET 11.0.0

Impact

Any consumer reading a DECIMAL or NUMERIC column on .NET 11 gets a wrong value, silently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions