Using increment on Decimal fields?
In the docs, it explicitly mentions atomic number operations like
increment
, decrement
etc. only works on Float
and Int
. https://www.prisma.io/docs/orm/reference/prisma-client-reference#atomic-number-operations
However, I tried it on a Decimal
field, and it seems to work fine. Does that mean I can use it without any issues? Or are there any issues that could pop up?
Part of my schema:
Query:
amountToUpdate
is a string.4 Replies
You selected to wait for the human sages. They'll share their wisdom soon.
Grab some tea while you wait, or check out
#ask-ai
if you'd like a quick chat with the bot anyway!The precision can be lost in some cases:
https://github.com/prisma/prisma/issues/18581
GitHub
Increment/decrement loses precision with decimal columns · Issue #...
Discussed in #18518 Originally posted by drishit96 March 27, 2023 I am trying to increment a column of type Decimal @db.Decimal(22, 4). It works for numbers which are supported by the number primit...
Thanks!
Yeah, I saw this issue on GH after creating this thread. I think it should be fine for my case, I won't have that many big numbers or lot of decimal points.
Sounds good! 👍