edgedb / edgedb-rust

The official Rust binding for EdgeDB
https://edgedb.com
Apache License 2.0
208 stars 26 forks source link

`edgedb_protocol::model::Decimal` is largely unusable #271

Open jquesada2016 opened 1 year ago

jquesada2016 commented 1 year ago

The Decimal type as provided is unusable without opting in to the with-bigdecimal feature flag. Without this, the type is completely opaque. Even if one does opt to using bigdecimal, it's an older version (0.3 rather than the current 0.4) so you get compilation errors when trying to convert a Decimal value into a BigDecimal value.

The two main improvements that can be done here are:

  1. Bumping the dependency version
  2. Adding crate-agnostic ways of getting the information needed in order to convert to another type, or at minimum, a Display implementation that can be used to parse into another type
aljazerzen commented 3 months ago

Those are both valid proposals.

I'm not sure why we don't expose the underlying fields publicly. I'm certain that they are not going to change, since we are not going to change the data wire format for decimals. So there is no concern about backward compatibility.

That said, they are quite unpleasant to work with. They are documented here: https://docs.edgedb.com/database/reference/protocol/dataformats#std-decimal