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:
parent
7fa92daa99
commit
f3e350d631
@ -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)
|
||||
|
||||
|
@ -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) #
|
||||
###############################################
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user