Decimal truncation occurs after 5 digits

Description

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 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.)

Environment

SQL Server

Activity

Alex Zaytsev 
November 26, 2017 at 11:00 PM

Migrated here.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created October 2, 2017 at 6:02 PM
Updated November 26, 2017 at 11:00 PM
Resolved November 26, 2017 at 10:59 PM
Who's Looking?