Numeric // Decimal Postgres types are inferred as strings and expect string as an input as well

No description
5 Replies
Dan
Dan2y ago
That is intentional - numeric and decimal are used to store values with huge precision/number of digits, so it only makes sense to store them as strings. For regular numbers, you can use integer, bigint, doublePrecision, real. Otherwise, how would you represent a number with 65 digits after the decimal point in JS?
rushil1o1
rushil1o1OP2y ago
Ah I see, so they're just converted to string to avoid losing precision in typescript ? if I pass a string representation to LTE and GTE queries, would is still correctly filter by Less Than and Greater Than?
Dan
Dan2y ago
I guess it depends on Postgres - if it supports LTE/GTE on numerics, I don't see why it shouldn't work.
rushil1o1
rushil1o1OP2y ago
Sounds good - for our use case we just decided to use double precision since it was within the precision limits we wanted and its better to not deal with string numbers in typescript
Dan
Dan2y ago
That's how we planned it to be used - if your precision limits can be expressed in JS, use double precision, otherwise use numeric with strings
Want results from more Discord servers?
Add your server