Open jayvdb opened 8 months ago
Sample implementations for numeric datatype can be found at https://github.com/search?q=postgres+Numeric+language%3Arust&type=code . It is commonly used for storing bigdecimals. Shouldn't be too hard to add to butane.
I quickly investigated diesel, and it doesnt appear to support u64
, except for MySQL.
SeaORM has a BigUnsigned
which is u64
. e.g. https://github.com/SeaQL/sea-orm/blob/a349f13/sea-orm-codegen/tests/expanded_with_schema_name/rust_keyword.rs#L28 However it is also only implemented in MySQL.
https://github.com/Electron100/butane/blob/9377e31/butane_core/src/codegen/mod.rs#L455-L456 says
https://www.postgresql.org/docs/current/datatype-numeric.html bigint is the spec compliant signed 8 bytes, which can not hold a u64 without comparisons & aggregations being incorrect.
For postgres, we could use the
numeric
datatype, which I guess is what that comment is referring to.For any backend that doesnt have a data type that can hold a u64, the u64 could be stored as a string, which will compare/sort correctly as long as the value is padded, and will aggregate reasonably well. We would likely want to put that impl behind a feature flag so people dont make use of the u64-as-string trick without being aware of the trade offs.