postgresql-unit icon indicating copy to clipboard operation
postgresql-unit copied to clipboard

Currencies support

Open tnelson-doghouse opened this issue 2 years ago • 2 comments

I saw in the documentation that you mentioned that currencies were an omission.

Would it be possible to support currencies with the caveat that they're only as up-to-date as the exchange rates in use?

Thanks!

tnelson-doghouse avatar Apr 15 '22 01:04 tnelson-doghouse

The current design is that internally, everything is broken down to units in the 7 SI units and "byte". These 8 exponents are then stored as 8 bytes along with the double precision value, so 8+8=16 bytes.

Adding currencies would require a basically unbounded number of base units. That's how GNU units works, so it would make sense to switch to that model, but it would be a new datatype with a different storage representation in PostgreSQL (most probably varlena-based).

I might actually implement that some day.

df7cb avatar Apr 15 '22 17:04 df7cb

Ah, that makes sense. Thanks!

tnelson-doghouse avatar Apr 15 '22 23:04 tnelson-doghouse