-
-
Notifications
You must be signed in to change notification settings - Fork 14
Opt-in trim_scale for decimal fields #414
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
Comments
I don't know why Postgres does that by default, but why is it a problem? That's a lot of work to support such SQL manipulations on a column level. |
So if that's a real problem, I'll keep this in plans, and allowing to specify that column the x needs to actually turn into some SQL expression when selecting may be useful here and in other use cases. But that's a lot of effort, and if it's not a big deal, there is no need to implement that. |
That's not exactly big deal, it's a "nice to have" one. So if you feel this does not belong to the backlog of how the ORM could be extended in future then sure can close the issue. |
The default Postgres behavior for decimal fields math operations is that the result has the precision of the maximum precision of its elements. That means, 0.333 + 0.367 is not 0.7 but 0.700:
This is inconvenient for real use. I end up using raw SQL for all math operations:
The same problem is with aggregates:
Question, would it be somehow possible to automatically apply
trim_scale
on the ORM level in increment/decrement and aggregate operations? Perhapst.decimal()
options could be changed to be an object with optional keys, including the new flag:The text was updated successfully, but these errors were encountered: