Merge branch 'patch-1' of https://github.com/oleksandr-l5/mongoengine
This commit is contained in:
commit
f6d864b6d1
@ -482,10 +482,11 @@ class DecimalField(BaseField):
|
|||||||
value = decimal.Decimal("%s" % value)
|
value = decimal.Decimal("%s" % value)
|
||||||
except (TypeError, ValueError, decimal.InvalidOperation):
|
except (TypeError, ValueError, decimal.InvalidOperation):
|
||||||
return value
|
return value
|
||||||
return value.quantize(
|
if self.precision > 0:
|
||||||
decimal.Decimal(".%s" % ("0" * self.precision)), rounding=self.rounding
|
return value.quantize(decimal.Decimal(".%s" % ("0" * self.precision)), rounding=self.rounding)
|
||||||
)
|
else:
|
||||||
|
return value.quantize(decimal.Decimal(), rounding=self.rounding)
|
||||||
|
|
||||||
def to_mongo(self, value):
|
def to_mongo(self, value):
|
||||||
if value is None:
|
if value is None:
|
||||||
return value
|
return value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user