You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error seems to occur specifically when using a Decimal128Field with certain parameters. This issue might be related to how the to_python method handles the value.
Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:
The text was updated successfully, but these errors were encountered:
The following code can fix this.
I want to know if this is the best practice for fixing this issue.
classDecimalField(Field):
''' Base class for all decimal fields. Can also be used directly. '''
...
def_round(self, value):
withlocalcontext() asctx:
ctx.prec=self.precisionreturnvalue.quantize(self.exp)
...
When initializing a model with a Decimal128Field in the clickhouse_orm library, a decimal.InvalidOperation error occurs under certain circumstances.
Reproducible Example:
Expected Behavior:
I expected the model TestDecimalModel to be initialized without any errors.
Environment Details:
Python version: 3.8.16
clickhouse_orm version: 2.1.0
Operating System: macOS 14.5
Additional Context:
The error seems to occur specifically when using a Decimal128Field with certain parameters. This issue might be related to how the to_python method handles the value.
from python docs
The text was updated successfully, but these errors were encountered: