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

Numeric type to use Decimal

Open wolframm opened this issue 1 year ago • 1 comments

IMO when one uses the expensive numeric type in Postgres one would do so because one would want it to behave like a Decimal as opposed to int,double or String. It would seem obvious to use the Dart type Decimal (i.e. GenericType<Decimal> from the decimal lib because it closely resembles the intent of numeric.

The encoding/decoding logic wouldn't change much, since Decimal can parse a String. But even if one added new Type.decimal and kept the current Type.numeric instead of changing it, this looks like a breaking change since PostgresBinaryDecoder wouldn't be able to tell the difference (as far as I can tell). Unless, one adds an optional useDecimalForNumeric flag in ConnectionSettings, but that seems messy.

What are your thoughts?

wolframm avatar Feb 19 '24 07:02 wolframm

I am asking this also in light of implementing numrange, which would either end up being a range of String (which makes no sense, I think) or be a range of Decimal, which would make more sense, but use an element type that is different than Type.numeric's.

wolframm avatar Feb 19 '24 13:02 wolframm