-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: add support for float properties #10551
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
5 Skipped Deployments
|
🦋 Changeset detectedLatest commit: c40d4b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 65 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
*/ | ||
if (field.dataType.name === "float") { | ||
Property({ | ||
columnType: "numeric", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: shouldn't this be real
or double precision
to mirror Postgres?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double checked it and it seems that you can loose some precision with real
and double
. For example: If I run the following query where the tax_rate_real
is a REAL
column, then the updated value will be 0.102111116
.
UPDATE "public"."foo" SET "tax_rate_real" = 0.102111114;
Ofcourse, in our case we don't need these many decimal places, but will be nice to cover them for other use-cases with a more accurate data-type. WDYY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I thought the argument for not using the bigNumber
column here and introducing float
was that we didn't care about high precision for tax rates. If we want to solve for the scenario you describe, would it not be more appropriate to just use bigNumber
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay with using REAL
. Have no strong arguments using numeric
.
The issue with bigNumber
was its representation within the JavaScript runtime. Not having the value next to the field and having it inside the _raw
property as an object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
Just to be clear, I think your argument for using numeric
makes sense–it offers higher precision for the rate of tax rates. That said, we introduced the bigNumber
property specifically for these use cases and I'd like us to continue using this whenever relevant to ensure consistency and leverage our existing utilities. That’s why I pushed back on adding a new type with somewhat similar characteristics. It’s not that high precision isn’t valid. I hope this rationale makes sense.
Let's go with real
now and we can revisit later if it leads to issues.
Fixes: FRMW-2844
This PR introduces the support for float values using DML. Under the hood, the value is stored as
numeric
with PostgreSQL and converted to a number using theNumber
serializer.The float values can be used to represent values with decimal precision. For example: