-
Notifications
You must be signed in to change notification settings - Fork 2.2k
$executeRaw throws PostgreSQL ERROR: invalid scale in external "numeric" value or inserts 0.0 #4828
Copy link
Copy link
Closed
prisma/prisma-engines
#1634Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: floating point typesTopic related to floating point types and precision lossTopic related to floating point types and precision losstopic: raw$queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli$queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli
Milestone
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: floating point typesTopic related to floating point types and precision lossTopic related to floating point types and precision losstopic: raw$queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli$queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli
Bug description
We are using $executeRaw to insert data into a table. If a decimal value is passed in the record will get inserted. If a whole number (1234, 1234.0) is passed in, the record will be inserted but the decimal value will be 0.0. If a larger whole number (12345, 12345.0) is passed in, Postgres will throw an error: ERROR: invalid scale in external "numeric" value
How to reproduce
Using
runRawQuery(1234.5, '032c9baa-0616-4361-8a40-7a808e5180f3', 'some notes')will create the record with the correct values.Using
runRawQuery(1234.0, '032c9baa-0616-4361-8a40-7a808e5180f3', 'some notes')will create the record but originalAmount will be 0.00Using
runRawQuery(12345.0, '032c9baa-0616-4361-8a40-7a808e5180f3', 'some notes')will cause Postgres to throw an error: ERROR: invalid scale in external "numeric" valueExpected behavior
I expect the record to get created with the correct values.
Environment & setup