mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #36030 Fixed inconsistent decimal for DIV MUL ADD and SUB operations
This commit is contained in:
parent
890aaca91a
commit
c9fbeffc0a
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,19 +0,0 @@
|
||||
# If you need to exclude files such as those generated by an IDE, use
|
||||
# $GIT_DIR/info/exclude or the core.excludesFile configuration variable as
|
||||
# described in https://git-scm.com/docs/gitignore
|
||||
|
||||
*.egg-info
|
||||
*.pot
|
||||
*.py[co]
|
||||
.tox/
|
||||
__pycache__
|
||||
MANIFEST
|
||||
dist/
|
||||
docs/_build/
|
||||
docs/locale/
|
||||
node_modules/
|
||||
tests/coverage_html/
|
||||
tests/.coverage*
|
||||
build/
|
||||
tests/report/
|
||||
tests/screenshots/
|
@ -61,6 +61,13 @@ class Combinable:
|
||||
BITXOR = "#"
|
||||
|
||||
def _combine(self, other, connector, reversed):
|
||||
if connector in [self.DIV, self.MUL, self.ADD, self.SUB] and isinstance(
|
||||
other, (int, float, Decimal)
|
||||
):
|
||||
other = Value(
|
||||
Decimal(str(other)),
|
||||
output_field=fields.DecimalField(max_digits=20, decimal_places=10),
|
||||
)
|
||||
if not hasattr(other, "resolve_expression"):
|
||||
# everything must be resolvable to an expression
|
||||
other = Value(other)
|
||||
@ -1172,6 +1179,8 @@ class Value(SQLiteNumericMixin, Expression):
|
||||
def resolve_expression(
|
||||
self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False
|
||||
):
|
||||
if isinstance(self.value, Decimal) and not self.output_field:
|
||||
self.output_field = fields.DecimalField(max_digits=20, decimal_places=10)
|
||||
c = super().resolve_expression(query, allow_joins, reuse, summarize, for_save)
|
||||
c.for_save = for_save
|
||||
return c
|
||||
|
Loading…
Reference in New Issue
Block a user