Skip to content

NH-4087 - Decimal truncation occurs after 5 digits #1196

Closed
@nhibernate-bot

Description

@nhibernate-bot

Frédéric Delaporte created an issue — 2nd October 2017, 18:02:42:

With Sql Server, setting a decimal parameter without specifying its precision and scale will cause any fractional part longest than 5 digits to be truncated, unless its precise precision and scale was determined by the query parsing (which usually occurs in case of simple comparison with an entity property).

This is due to an optimization for SQL Server query plan cache which set decimal parameters precision and scale to their "max" values in <SqlClientDriver>(https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Driver/SqlClientDriver.cs#L133) if they do not specify those themselves. And "max" scale is only 5.

Any way, max scale is non-sens, since it is indeed equal to precision for most databases, in which case their are no more digits before the dot. It is more a default scale.

Such an optimization, causing parameter truncation, should not be enable by default. Such a default scale should be at least configurable. (Or completely removed.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions