-
Notifications
You must be signed in to change notification settings - Fork 112
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
Error: Invalid length for float8 #147
Comments
Similar case with Int8. Trying to scan bigint into Int8 but got the following error Line 206 in 94e10b9
|
PostgreSQL It's a fundamental design constraint with the pgtype system. Every type is designed to work with only one underlying PostgreSQL type. Because Incidentally, I've made a significant rewrite of pgtype in the pgx As far as what you can do now, you could force the text format for that query by using |
Thank for the response, it solved my problem. And. sorry for the delay, just got back to this. One more thing, is there a reason for not having Marshal/Unmarshal JSON for Float4 and Float8? Because if it did, it would be a lot easier for me. I could just use For now, I scan into shopspring.Numeric and use the below function because I don't want numeric to be string in JSON response.
|
Only reason is no one got around to it.
Some JSON parsers will lose information if your data does not neatly fit in to a float64. That is why it can make sense to have numeric be represented as a string in JSON. |
I want to scan a numeric(30,6) field into Float8. But, I get the following error
pgtype/float8.go
Line 207 in 94e10b9
I tried using float64 directly and it works fine. But, I wanna handle null values, hence the use of Float8.
For now, I am scanning into shopspring-numeric and converting it into float64 using AssignTo()
(Note: It's not a currency value field, so okay to lose precision.)
The text was updated successfully, but these errors were encountered: