Skip to content
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

fix(client): Serialize all Floats in exponential notation #15879

Merged
merged 9 commits into from Oct 19, 2022

Conversation

cmd-johnson
Copy link
Contributor

@cmd-johnson cmd-johnson commented Oct 19, 2022

This should fix #12651, #13317 and #15551 by always serializing Float fields in GraphQL queries in exponential notation.

I added a unit test for the serialization and a integration test that verifies that large floats can now be inserted into the database and updated other tests that used floats to match the new serialization behavior.

In order to properly test this, I also had to change the regex used by the jestSnapshotSerializer in normalizeMigrateTimestamps, because it interfered with all long numbers in snapshots. E.g. -9.007199254740991e+15 would get replaced with -9.202012310000001e+15, which made snapshots appear to test for a wrong value. I updated snapshots that had the same problem accordingly.

Fixes #12651
Fixes #13317
Fixes #15551

@cmd-johnson cmd-johnson requested a review from a team October 19, 2022 06:28
@cmd-johnson cmd-johnson requested review from danstarns and removed request for a team October 19, 2022 06:28
@CLAassistant
Copy link

CLAassistant commented Oct 19, 2022

CLA assistant check
All committers have signed the CLA.

@cmd-johnson cmd-johnson changed the title Always serialize float fields in exponent notation fix(client): Serialize all Floats in exponential notation Oct 19, 2022
@SevInf SevInf self-requested a review October 19, 2022 09:31
@SevInf SevInf self-assigned this Oct 19, 2022
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.
Copy link
Contributor

@SevInf SevInf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cmd-johnson!
Thank you for the great contribution, especially adding both unit & integration tests!

I've made a couple of changes to the PR:

  • converted intergration test to a functional one. This a newer, more powerful test suite and we generally add new tests there and consider integration suite to be a legacy.

Once CI is green, I'll merge your contribution. Then, it will be released as a part of prisma 4.6.0.

@SevInf SevInf added this to the 4.6.0 milestone Oct 19, 2022
@aqrln
Copy link
Member

aqrln commented Oct 19, 2022

Also fixes #15551

UPD: I went ahead and updated the PR message

Co-authored-by: Alexey Orlenko <alex@aqrln.net>
@SevInf SevInf merged commit 4732879 into prisma:main Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants