New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Float values around 2^63 get interpreted as invalid intergers and throw a graphql error #15551
Comments
Could you try to use Decimal with precision to get more byte to store? |
updated model: model Test {
id Int @id @default(autoincrement())
value Decimal
} produces the same error:
both Float and Decimal allow storage of these values, its just the query that fails to serialize. |
It might be related to #14632 (comment) |
I can reproduce this. mutation {
createOneTest(data: {
value: 18446744073709552000
}) {
id
value
}
} {
"errors": [
{
"error": "Query parsing failure: A number used in the query does not fit into a 64 bit signed integer. Consider using `BigInt` as field type if you're trying to store large integers.",
"user_facing_error": {
"is_panic": false,
"message": "Query parsing failure: A number used in the query does not fit into a 64 bit signed integer. Consider using `BigInt` as field type if you're trying to store large integers.",
"meta": {
"details": "Query parsing failure: A number used in the query does not fit into a 64 bit signed integer. Consider using `BigInt` as field type if you're trying to store large integers."
},
"error_code": "P2033"
}
}
]
} When changing the number to have mutation {
createOneTest(data: {
value: 18446744073709552000.0
}) {
id
value
}
} {
"data": {
"createOneTest": {
"id": 1,
"value": 18446744073709550000
}
}
} Since the client knows the expected type is |
do you know where in the code that serialization happens, i'd like to take a look at exactly whats going on there; maybe could make a fix |
@paperdave sorry, I didn't see your response! It looks like your issue is a duplicate of #12651 and #13317, and we got a pull request today that should fix all three issues, please take a look at it too if you are interested: #15879 |
Bug description
Running the
create
method with any schema with aFloat
column with the value2**64
fails.After some digging, it seems that the graphql query stringifies the number to
18446744073709552000
, which graphql wrongly interprets as an integer. Passing values around2**70
function as it seems they get serialized as1.1805916207174113e+21
.This means we cannot insert numbers from around ~
2**63
to ~2**69
for our app. Can't insert them via prisma studio either.I dont know the codebase much, but would this be fixed if ".0" was suffixed to numbers that the
e
notation doesn't have?How to reproduce
Expected behavior
The value
18446744073709552000
should be written to the database as a float.Prisma information
prisma/schema.prisma
test.mjs
using
DEBUG=*
i found this graphql querythe
value: n
is what im referring to above about the stringified valueEnvironment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: