Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Bigdecimal conversion in Postgres is limited to u128 #345

Open
snf opened this issue Jan 20, 2022 · 3 comments
Open

Bigdecimal conversion in Postgres is limited to u128 #345

snf opened this issue Jan 20, 2022 · 3 comments

Comments

@snf
Copy link

snf commented Jan 20, 2022

What the title says. The lib doesn't currently support the variable numeric type: https://www.postgresql.org/docs/9.1/datatype-numeric.html which says up to 131072 digits before the decimal point; up to 16383 digits after the decimal point. It crashes if it's used with a numeric type beyond 2^128 because of the code in this function: https://github.com/prisma/quaint/blob/main/src/connector/postgres/conversion/decimal.rs#L81

Opinions on the best way to fix it? I can try submitting a PR if I get some time this week.

I realised that the PR #344 only stops the crash but the underlying issue is that large numeric types aren't supported

@snf
Copy link
Author

snf commented Jan 20, 2022

This is how that library makes the conversion but unfortunately it doesn't support base 10_000 as needed by quaint https://github.com/rust-num/num-bigint/blob/master/src/biguint/convert.rs#L646 . Could potentially copy and optimize that function in.

@richardwu
Copy link

Just ran into this issue as well: I've added a small repro here https://github.com/richardwu/prisma-decimal

@zipzapzanigan
Copy link

+1 on this issue, stuck until i can find a fix...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants