[PostgreSQL] Cannot create or update row with large Decimal value within `numeric` range
See original GitHub issueBug description
I have a schema with a model which has a Decimal
value. When I try to create or update an entry passing as value a large number such as Prisma.Decimal('93431006234343600001')
, the operation fails with the following error
Error parsing GraphQL query: query parse error: Parse error at 3:12
number too large to fit in target type
How to reproduce
I have created a reproduction repo which can be found at https://github.com/codazzo/prisma-decimal-precision-repro
Expected behavior
My understanding is that with a Decimal
type I should be able to run
await prisma.entry.create({
data: {
value: new Prisma.Decimal('93431006234343600001')
}
})
Note that I am able to find
any entities that hold large values from the DB.
If the value is 93431006234343600001
in the DB, I can successfully call prisma.entry.findUnique()
and get the value back.
Prisma information
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Entry {
id Int @id @default(autoincrement())
value Decimal
}
Environment & setup
OS: macOS Big Sur 11.6.2 Kernel Version 20.6.0 Database: PostgreSQL 14.1 Node version: v16.9.1
Prisma Version
prisma : 3.8.1
@prisma/client : 3.8.1
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f
Studio : 0.452.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Documentation: 9.3: Numeric Types - PostgreSQL
The types smallint, integer, and bigint store whole numbers, that is, numbers without fractional components, of various ranges. Attempts to store values outside ......
Read more >PostgreSQL: how to resolve "numeric field overflow" problem
If you get number(17, 17 ) - you say: number will store 17 digits as a whole AND reserve 17 digits for decimal...
Read more >Numeric value does not fit in a System.Decimal #438 - GitHub
Am I correct in understanding that a PostgreSQL decimal value inserted months ago, via Npgsql, had a scale of 30 in the database?...
Read more >PostgreSQL Numeric - Javatpoint
Note: In PostgreSQL, the Numeric data type can have a value of up to 131,072 digits before the decimal point of 16,383 digits...
Read more >Exploring the various Postgres data types - The Quest Blog
For example, you should use the smallint data type for a table with a limited number of rows. Postgres displays an error –...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Do we have any update on this or a progress update here? A project I am working on is blocked by this.
I’m hitting this problem too, and with BigInt column type.
Please add some basic test cases for this and fix it asap, basically all big number support is broken.