Postgres: Improve error message when getting invalid scale/precision …#781
Merged
MaxGabriel merged 1 commit intomasterfrom Feb 14, 2018
Merged
Postgres: Improve error message when getting invalid scale/precision …#781MaxGabriel merged 1 commit intomasterfrom
MaxGabriel merged 1 commit intomasterfrom
Conversation
…for numeric values
18af641 to
6c8bd8a
Compare
MaxGabriel
commented
Feb 8, 2018
| , ". Postgres defaults to a maximum scale of 147,455 and precision of 16383," | ||
| , " which is probably not what you intended." | ||
| , " Specify the values as numeric(total_digits, digits_after_decimal_place)." | ||
| ] |
Member
Author
There was a problem hiding this comment.
An alternative to this error message would be to try to use a numeric value with extremely high scale and precision. It isn't possible to match the Postgres maximums, because the unspecified value has a precision of 16383, while the Postgres docs say:
The maximum allowed precision when explicitly specified in the type declaration is 1000
See table 8.2 for these limits: https://www.postgresql.org/docs/10/static/datatype-numeric.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…for numeric values
I ran into this error recently when not specifying precision for a numeric column, and the error message was pretty bad (it didn't tell you the table or column name that was the problem)
I also cleaned up the variable names. They were named things like
xorywhich made it pretty hard to tell what was what.Before submitting your PR, check that you've:
After submitting your PR: