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
Cannot insert Floats (≥9.223372037e18 and <1e21) or (>-1e21 and ≤-9.223372037e18) #12651
Comments
My guess on the problem source is that JS by default only serializes numbers with an exponent >20 in scientific notation. |
With 3.15 a change ships that will surface better errors, but doesn't fully address this ticket yet. A follow-up ticket will fix that we currently can't utilise the entire float range because of GraphQL serialisation issues. |
Related: #13317 |
I can reproduce this, even with the latest Prisma version at this point (4.3.1). Something to do with the validation logic. |
* test(client): unit test for #12651 * test(client): integration test for #12651 * fix(client): Serialize all floats in exponential notation Fix #12651, fix #13317 * test(internals): Fix normalizeMigrateTimestamps applying to all long numbers * test(client): Convert large-floats tests to functional * test(client): Revert snapshot serializer changes It does not seem that it was indendened for snapshot serizier to apply to select.test.ts. Instead, we are fixing the failure by changing the number so it won't be replaced by serializer. * Revert "test(client): Revert snapshot serializer changes" This reverts commit 7756be2. * Update packages/internals/src/utils/jestSnapshotSerializer.js Co-authored-by: Sergey Tatarintsev <sergey@tatarintsev.me> Co-authored-by: Alexey Orlenko <alex@aqrln.net>
Bug description
Trying to set fields defined as
Float
in the Schema to values ≥9.223372037e18
and <1e21
fails with the following error:Additionally, trying to set values >
-1e21
and ≤-9.223372037e18
throws as well:I've first encountered this with postgresql, but it happens with sqlite as well.
I'm guessing there is something going wrong while parsing the generated GraphQL query.
Calling the reproduction script with
1e20
throws while trying to execute the following query that was generated byprisma:client
:Running that same query manually through the
query-engine
's GraphQL playground yields the same error, but when writing the value in exponential notation (1e20
), the mutation works just fine.How to reproduce
npm install
oryarn install
)postinstall
hook will automatically create atest.db
sqlite DB and apply the only required migrationnode index.js [number]
will attempt to insert the value you pass it as an argument into the database. Try it with:1e20
1e21
9.223372037e18
9.223372036e18
-1e20
-1e21
-9.223372037e18
-9.223372036e18
This can also be reproduced when running the Prisma query-engine directly, with some key differences:
query-engine --datamodel-path ./schema.prisma -g
1e20
100000000000000000000
(==1e20
, but written out)Expected behavior
All examples should work without throwing.
Prisma information
Schema:
Code: (see reproduction repo for more)
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: