Open roji opened 2 years ago
Thanks @roji, We'll check and will get back to you.
It seems that some logic is incorrect in sqlbuffer or somewhere else. There were some issues years ago about precision and scale and some fixes have been made. Things that i have read about: decimal(38,20) to .net decimal , decimal(38,18) to net and one more wich i cant find now.
Seems some fixes helped, since i can save 2342342,35467895678945678956 now into (38,20), but i accidentally got new bug. i am using sql server and ef core 7.0.11. My database decimal type is decimal(38,20) and i am getting overflow exception when trying to save 9999999999999 (13 nines, notice that 12 nines is ok) for example.
i have quick look at sqlbuffer but could not find bug yet
For the record, when the scale is going to change SqlDecimal.AdjustScale
is called. The return value is a SqlDecimal
and an attempt to retrieve data from the Value
property throws the overflow exception. This exception comes from System.Data.SqlTypes.SqlDecimal
and I think the fix should be proposed from the related library.
I also run into this issue.
https://github.com/dotnet/efcore/issues/33109
Why is this only Low Priority. How can we workaround this?
A possible mentioned workaround here is not a viable solution. See the comment by @roji here.
IIRC it's important to set the precision/scale on the parameter, otherwise various issues can occur (e.g. with Always Encrypted); however, I agree it's odd that this causes the above failure.
It's been a while and haven't seen much update on this. We are also having issue storing decimal value with 28 precision on a decimal(38,10). Our code was heavy on EF and it will hard adding non-EF workaround. Any updates on this?
@shidcordero, @IT-CASADO this issue is related to underlying APIs and it would be better addressed in the related API, as I mentioned here.
@shidcordero If you have another issue, feel free to open a new issue and file your repro for further investigation.
It seems like it's possible to write decimal.Max into a
decimal(38, 4)
column, as long as Precision and Scale aren't set on the parameter. The moment they are set, an exception is thrown. In EF Core, we always set the Precision/Scale because it's necessary for Always Encrypted to function correctly.Exception:
Full repro:
Originally reported in https://github.com/dotnet/efcore/issues/28240