-
Notifications
You must be signed in to change notification settings - Fork 51
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
All rational numbers are parsed as Decimals.Decimal instead of Float #254
Comments
Only columns with type The You can either force the type in Julia: julia> execute(conn, sql; type_map=Dict(:numeric => Float64)).column_types
3-element Vector{Type}:
Float64
Float64
Float64 or in SQL: julia> sql="""
select avg(1.0)::float8 as average, 1.0::float8 as float_number, 0.0000000001::float8 as really_small_number;
"""
"select avg(1.0)::float8 as average, 1.0::float8 as float_number, 0.0000000001::float8 as really_small_number;\n"
julia> execute(conn, sql).column_types
3-element Vector{Type}:
Float64
Float64
Float64 |
|
Thank you for the explanation, @iamed2! I've been eyeing I'll close the issue as LibPQ works as expected. Some additional background: As for the python side, you're right. Good learning! |
I have noticed unexpected behaviour. It might be intended but I haven't found any reference in the documentation.
Expected behaviour: rational numbers like 1.0 and 0.1 will be represented as Float
Actual behaviour: all non-integer numbers are represented as Decimals.Decimal
MWE:
Package version (but I've seen the same behaviour on 0.9)
[194296ae] LibPQ v1.14.0
versioninfo() (but it was the same on 1.7)
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
OS: macOS (arm64-apple-darwin21.3.0)
CPU: 8 × Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
Threads: 6 on 6 virtual cores
The text was updated successfully, but these errors were encountered: