Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric Value out of Range, when range is set well above the reported error #16

Open
squareleaf opened this issue Jan 22, 2024 · 3 comments

Comments

@squareleaf
Copy link

I see that there's an existing issue #8 for this, but it's also marked as answered. Since there's no resolution or answer on the issue, I'm posting a new issue.

I'm getting the following error whenever I try to add a new rating:
PG::NumericValueOutOfRange: ERROR: numeric field overflow (ActiveRecord::RangeError)
DETAIL: A field with precision 17, scale 14 must round to an absolute value less than 10^3.

The average and estimate fields are both:

t.decimal "average", precision: 25, scale: 16, default: "0.0"
t.decimal "estimate", precision: 25, scale: 16, default: "0.0"

I am writing a value of either 1 or 5 as a rating. I have queried and there are no records in the database with an absolute value greater than 9. I deleted all the records with an absolute value less than 0.1.

All this leads me to believe that there is something wrong in the gem of the code itself. I'll write a PR if someone can point me to a possible source of the error.

@wbotelhos
Copy link
Owner

Hi, @squareleaf Thanks for let me know about the issue. I wrote some explanation that leads me to a bug. I'm about to release a new version where you can test against. Feel free to close this issue and continue the thread there.

@squareleaf
Copy link
Author

Looks like your fix took care of our issue. Sorry it took me so long to check it out!

@squareleaf
Copy link
Author

squareleaf commented Jul 16, 2024

I spoke too soon. I pushed out a fix to our codebase switching it to use your newest gem code and got the following Sentry error from production:

PG::NumericValueOutOfRange: ERROR: numeric field overflow (ActiveRecord::RangeError)
DETAIL: A field with precision 17, scale 14 must round to an absolute value less than 10^3.

@squareleaf squareleaf reopened this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants