df7cb / postgresql-unit

SI Units for PostgreSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Currencies support

tnelson-doghouse opened this issue · 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!

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.

Ah, that makes sense. Thanks!