Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upBetter handling of Numeric type #841
Comments
This comment has been minimized.
|
See PR #837. Would you be interested in a direct conversion to |
This comment has been minimized.
|
@rubdos Numeric is something like a decimal type, right? so I guess what we'd lose is precision? |
killercup
added
the
enhancement
label
Apr 5, 2017
This comment has been minimized.
|
I'd be fine with losing precision from |
This comment has been minimized.
|
If Numeric is a decimal type, maybe there's a loss-free decimal type available in the Rust ecosystem? Or maybe we could add our own wrapper that can be converted to a float explicitly, if desired? |
This comment has been minimized.
I refer again to #837; that directly solves this issue. The loss-free decimal type in the Rust ecosystem is done by the |
This comment has been minimized.
|
Next up is finishing #837; I think all of what I need is available in BigDecimal or its merge requests now. |
This comment has been minimized.
|
Alright! #837 is on master. So, the next question is: What needs to happen to make this easily usable?
Open points from #837:
(Do we want to make this a meta issue for all things Numeric? I can move the todo lists to the main issue descriptions. Also, feel free to add more points, or open new issues for parts of this!) |
This comment has been minimized.
Actually, I want to vote "no" on this. Although Rust does very well enforce types, I think this might confuse users. When you have Numeric in your database, you don't "just" want to read it out as
Good with me. |
This comment has been minimized.
I grant you this and this file under both Apache 2.0 and MIT licenses; so you can use the code to put it in examples. I don't have migrations in that project, but feel free to ask for more files if you want. There are example insertions, and example selections, and even some other fancy logic to make an invoice from them. |
dbrgn commentedApr 5, 2017
Some operations like
avg()on an integer field returnNumeric, which isn't currently mapped to any Rust type. I didn't find out how to actually retrieve the resulting value. Is it even possible?See #840.