fix-#787: Fix storing value of precision attribute in DecimalField
This commit is contained in:
		| @@ -5,6 +5,7 @@ Changelog | |||||||
|  |  | ||||||
| Changes in 0.9.X - DEV | Changes in 0.9.X - DEV | ||||||
| ====================== | ====================== | ||||||
|  | - Fix storing value of precision attribute in DecimalField #787 | ||||||
| - Querying by a field defined in a subclass raises InvalidQueryError #744 | - Querying by a field defined in a subclass raises InvalidQueryError #744 | ||||||
| - Add Support For MongoDB 2.6.X's maxTimeMS #778 | - Add Support For MongoDB 2.6.X's maxTimeMS #778 | ||||||
| - abstract shouldn't be inherited in EmbeddedDocument # 789 | - abstract shouldn't be inherited in EmbeddedDocument # 789 | ||||||
|   | |||||||
| @@ -308,7 +308,7 @@ class DecimalField(BaseField): | |||||||
|         self.min_value = min_value |         self.min_value = min_value | ||||||
|         self.max_value = max_value |         self.max_value = max_value | ||||||
|         self.force_string = force_string |         self.force_string = force_string | ||||||
|         self.precision = decimal.Decimal(".%s" % ("0" * precision)) |         self.precision = precision | ||||||
|         self.rounding = rounding |         self.rounding = rounding | ||||||
|  |  | ||||||
|         super(DecimalField, self).__init__(**kwargs) |         super(DecimalField, self).__init__(**kwargs) | ||||||
| @@ -322,7 +322,7 @@ class DecimalField(BaseField): | |||||||
|             value = decimal.Decimal("%s" % value) |             value = decimal.Decimal("%s" % value) | ||||||
|         except decimal.InvalidOperation: |         except decimal.InvalidOperation: | ||||||
|             return value |             return value | ||||||
|         return value.quantize(self.precision, rounding=self.rounding) |         return value.quantize(decimal.Decimal(".%s" % ("0" * self.precision)), rounding=self.rounding) | ||||||
|  |  | ||||||
|     def to_mongo(self, value, use_db_field=True): |     def to_mongo(self, value, use_db_field=True): | ||||||
|         if value is None: |         if value is None: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user