Conversation
|
Attempt of #126 ( @pynixwang ) |
|
directly replace |
fea0303 to
4f81c1a
Compare
|
@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: |
src/pg_ext/big_decimal.cr
Outdated
| struct Numeric | ||
| # Returns a BigDecimal representation of the numeric. This retains all precision. | ||
| def to_big_d | ||
| return BigDecimal.new("0") if nan? || ndigits == 0 |
There was a problem hiding this comment.
Just noticed that this should be BigDecimal.new(0) to avoid unnecessary allocation...
|
The new patch has a travis failure @greenbigfrog |
|
scientific notation is not support ? |
|
As said, you need the patches I linked in #132 (comment) |
a4be24c to
5a01c3e
Compare
5a01c3e to
d8082a2
Compare
d8082a2 to
e12b255
Compare
e12b255 to
764797e
Compare
|
Realized today that this doesn't allow to do math in the query itself (eg |
764797e to
eac915b
Compare
| # Returns a BigDecimal representation of the numeric. This retains all precision. | ||
| def to_big_d | ||
| return BigDecimal.new(0) if nan? || ndigits == 0 | ||
| BigDecimal.new(to_s) |
There was a problem hiding this comment.
There is pg/pg_ext/big_rational so this method can become:
def to_big_d : BigDecimal
to_big_r.to_big_d
endIn fact, maybe both files could be merged into a single pg/pg_ext/big file?
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)
This change is