add bigdecimal
Most likely not the optimal solution, but it'll do the job. Require #131 to work. (This will most likely only work on master crystal)
Attempt of #126 ( @pynixwang )
directly replace PG:: Numeric with BigDecimal will be better?
@will have you looked at this yet?
@greenbigfrog thanks. I'm curious though why you said it requires #131?
It requires a few patches that haven't been released yet (and back when I opened this PR, I had no idea rly how crystal's compiling worked). It only requires following PRs:
https://github.com/crystal-lang/crystal/pull/5582
https://github.com/crystal-lang/crystal/pull/5589
(and maybe https://github.com/crystal-lang/crystal/pull/5525 , not sure if it's required for the functionality of this PR. (I did need it for my project though))
The new patch has a travis failure @greenbigfrog
1) PG::Numeric to_big_d
Invalid BigDecimal: -9.0e-5 (Unexpected 'e' character)
/usr/share/crystal/src/big/big_decimal.cr:0:9 in 'initialize'
/usr/share/crystal/src/big/big_decimal.cr:78:5 in 'initialize'
/usr/share/crystal/src/big/big_decimal.cr:77:3 in 'new'
/numeric_spec.cr:14:3 in 'bd'
/usr/share/crystal/src/spec/expectations.cr:0:7 in '~procProc(Nil)'
/usr/share/crystal/src/spec/methods.cr:255:3 in 'it'
/usr/share/crystal/src/spec/methods.cr:0:5 in '~procProc(Nil)'
/usr/share/crystal/src/spec/context.cr:255:3 in 'describe'
/usr/share/crystal/src/spec/methods.cr:16:5 in 'describe'
spec/pg/encoder_spec.cr:1:1 in '__crystal_main'
/usr/share/crystal/src/crystal/main.cr:11:3 in '_crystal_main'
/usr/share/crystal/src/crystal/main.cr:112:5 in 'main_user_code'
/usr/share/crystal/src/crystal/main.cr:101:7 in 'main'
/usr/share/crystal/src/crystal/main.cr:135:3 in 'main'
__libc_start_main
???
???
scientific notation is not support ?
As said, you need the patches I linked in https://github.com/will/crystal-pg/pull/132#issuecomment-363595010 Mainly actually only https://github.com/crystal-lang/crystal/pull/5582 now that I think of it.
Realized today that this doesn't allow to do math in the query itself (eg -1 * 1.1) since it only passes it in as string (-1 * '1.1')