Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Wrong unconvert for Decimal #48

Open
DontStopMeNow opened this issue Apr 30, 2021 · 1 comment
Open

Wrong unconvert for Decimal #48

DontStopMeNow opened this issue Apr 30, 2021 · 1 comment

Comments

@DontStopMeNow
Copy link

DontStopMeNow commented Apr 30, 2021

There is a problem with unconverting Decimal. str(value) makes a float-like string that is cause of No operation equals between Decimal(19, 2) and Float64 error.

@staticmethod
    def unconvert(value: Decimal) -> bytes:
        return str(value).encode()

So, we made a monkey patch.

from aiochclient.types import Decimal, PY_TYPES_MAPPING

def unconvert_patch(value: Decimal) -> bytes:
    return f"toDecimal64('{value}', {abs(value.as_tuple().exponent)})".encode()

PY_TYPES_MAPPING[Decimal] = unconvert_patch

It had been working until the cython implementation was used inside docker =(
We are not good at cython, therefore there are no monkey patch for it or a pull request for the whole problem.

@maximdanilchenko
Copy link
Owner

@DontStopMeNow hi! Sorry for such late response.
Can you please give more detailed example? Table structure and how you insert and fetch this data. Because I can't reproduce it by myself.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants