oj: invalid value for BigDecimal(): "-e1535637460290" (ArgumentError)
Repro:
$ ruby -v
ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-darwin16]
$ gem install oj
Fetching: oj-3.6.10.gem (100%)
Building native extensions. This could take a while...
Successfully installed oj-3.6.10
Parsing documentation for oj-3.6.10
Installing ri documentation for oj-3.6.10
Done installing documentation for oj after 2 seconds
1 gem installed
$ ruby -r oj -e 'Oj.load("{\"number\":-e1535637460290}")'
-e:1:in `BigDecimal': invalid value for BigDecimal(): "-e1535637460290" (ArgumentError)
from -e:1:in `load'
from -e:1:in `<main>'
For reference, this is not a problem using Ruby 2.3:
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-darwin16]
$ gem install oj
Fetching: oj-3.6.10.gem (100%)
Building native extensions. This could take a while...
Successfully installed oj-3.6.10
Parsing documentation for oj-3.6.10
Installing ri documentation for oj-3.6.10
Done installing documentation for oj after 3 seconds
1 gem installed
$ ruby -r oj -e 'Oj.load("{\"number\":-e1535637460290}")'
$ echo $?
0
I think the problem is related to https://github.com/ruby/bigdecimal/issues/47, https://github.com/kubo/ruby-oci8/pull/144
$ chruby-exec 2.3 -- ruby -r bigdecimal -e 'puts BigDecimal("-e1535637460290").inspect'
#<BigDecimal:7f9090a31330,'-0.0',9(9)>
$ chruby-exec 2.4 -- ruby -r bigdecimal -e 'puts BigDecimal("-e1535637460290").inspect'
-e:1:in `BigDecimal': invalid value for BigDecimal(): "-e1535637460290" (ArgumentError)
from -e:1:in `<main>'
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (10 by maintainers)
Thank you @ohler55, it works as expected
Released as Oj 3.7.9.
I’ll look into it. I thought I added a unit test for that. Must not have though.
Great, will release as soon as I get some feedback on the other feature in the branch.
oh yeah, the other parsers too. On it.