1
0
mirror of https://github.com/django/django.git synced 2024-11-18 07:26:04 +00:00

Replaced typecast_decimal() with decimal.Decimal().

This commit is contained in:
Sergey Fedoseev 2017-08-11 18:22:40 +05:00 committed by Tim Graham
parent 7fa92daa99
commit f3e350d631
3 changed files with 3 additions and 9 deletions

View File

@ -39,7 +39,7 @@ Database.register_converter("date", decoder(parse_date))
Database.register_converter("datetime", decoder(parse_datetime))
Database.register_converter("timestamp", decoder(parse_datetime))
Database.register_converter("TIMESTAMP", decoder(parse_datetime))
Database.register_converter("decimal", decoder(backend_utils.typecast_decimal))
Database.register_converter("decimal", decoder(decimal.Decimal))
Database.register_adapter(decimal.Decimal, backend_utils.rev_typecast_decimal)

View File

@ -160,12 +160,6 @@ def typecast_timestamp(s): # does NOT store time zone information
)
def typecast_decimal(s):
if s is None:
return None
return decimal.Decimal(s)
###############################################
# Converters from Python to database (string) #
###############################################

View File

@ -1,9 +1,9 @@
import copy
import datetime
from contextlib import suppress
from decimal import Decimal
from django.core.exceptions import EmptyResultSet, FieldError
from django.db.backends import utils as backend_utils
from django.db.models import fields
from django.db.models.query_utils import Q
from django.utils.deconstruct import deconstructible
@ -289,7 +289,7 @@ class BaseExpression:
elif internal_type.endswith('IntegerField'):
return int(value)
elif internal_type == 'DecimalField':
return backend_utils.typecast_decimal(value)
return Decimal(value)
return value
def get_lookup(self, lookup):