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
Decimal type related functionality is missing #122
Comments
Thanks @gszabo and apologies for slow reply. This is simply a gap - we'd welcome a PR that added it. Please feel free to propose a design here and we can advise before you start implementing - I guess the key question is what Rust type to use. The functionality is present in the underlying cassandra-sys-rs crate, so it's just this crate that needs to be updated. |
I was playing around with this a little bit. Cpp driver provide 3 values: as an example, number 6.31: This is fine, now tricky part. Cassandra can return more that 16 bytes which doesn't fit to i128. For example, this is valid cassandra decimal value: size:17, scale:31 Deep dive to cql docu follow me to java type BigDecimal (https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html) I was looking for some implementation of bigdecimal crates, but I didn't found anything satisfying. Here is my implementation of get_dec(), but I have limit to max number which can be saved to DB.
|
Thanks. I'd rather we didn't roll our own bignum type. A quick search on crates.io turned up two likely options:
There were others, but they looked less well maintained or used. (I may have missed some though.) There's an interesting table here https://github.com/rust-num/num-bigint#alternatives but many of those are just big integer libraries; they don't do decimals. There's also num-rational, but that doesn't have any special handling for decimals, so (e.g.) printing wouldn't come out right. I prefer to avoid additional dependencies, so prefer https://crates.io/crates/bigdecimal . What do you think? |
This pass my tests, but more tests are required...
|
Thanks - that looks perfectly fine to me :-) |
this can be closed |
Thanks for flagging! Indeed, fixed in #177 . |
I noticed the Decimal type related functionality of the driver is not exported in this crate. For example the
bind_decimal
method is commented out: https://github.com/Metaswitch/cassandra-rs/blob/master/src/cassandra/statement.rs#L682What is the reason behind that? Is there a workaround clients can use? What would need to be solved so this crate can expose that functionality?
The text was updated successfully, but these errors were encountered: