mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Fixed #28932 -- Prevented Oracle from truncating trailing zeros in the fractional part of DecimalField.
Fixes the test added in 6fd6d8383f48ea2fe4e058725fa30529a083e9a5. Regression in 7c1f3901bcdabb1340a621e7df9b24f3acd0d6f3.
This commit is contained in:
parent
fc9eec7bb7
commit
c8a85e3e91
@ -401,6 +401,14 @@ class FormatStylePlaceholderCursor:
|
|||||||
def _output_number_converter(value):
|
def _output_number_converter(value):
|
||||||
return decimal.Decimal(value) if '.' in value else int(value)
|
return decimal.Decimal(value) if '.' in value else int(value)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_decimal_converter(precision, scale):
|
||||||
|
if scale == 0:
|
||||||
|
return int
|
||||||
|
context = decimal.Context(prec=precision)
|
||||||
|
quantize_value = decimal.Decimal(1).scaleb(-scale)
|
||||||
|
return lambda v: decimal.Decimal(v).quantize(quantize_value, context=context)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _output_type_handler(cursor, name, defaultType, length, precision, scale):
|
def _output_type_handler(cursor, name, defaultType, length, precision, scale):
|
||||||
"""
|
"""
|
||||||
@ -421,7 +429,7 @@ class FormatStylePlaceholderCursor:
|
|||||||
elif precision > 0:
|
elif precision > 0:
|
||||||
# NUMBER(p,s) column: decimal-precision fixed point.
|
# NUMBER(p,s) column: decimal-precision fixed point.
|
||||||
# This comes from IntegerField and DecimalField columns.
|
# This comes from IntegerField and DecimalField columns.
|
||||||
outconverter = int if scale == 0 else decimal.Decimal
|
outconverter = FormatStylePlaceholderCursor._get_decimal_converter(precision, scale)
|
||||||
else:
|
else:
|
||||||
# No type information. This normally comes from a
|
# No type information. This normally comes from a
|
||||||
# mathematical expression in the SELECT list. Guess int
|
# mathematical expression in the SELECT list. Guess int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user