Kaydet (Commit) c8a85e3e authored tarafından Sergey Fedoseev's avatar Sergey Fedoseev Kaydeden (comit) Tim Graham

Fixed #28932 -- Prevented Oracle from truncating trailing zeros in the…

Fixed #28932 -- Prevented Oracle from truncating trailing zeros in the fractional part of DecimalField.

Fixes the test added in 6fd6d838.
Regression in 7c1f3901.
üst fc9eec7b
......@@ -401,6 +401,14 @@ class FormatStylePlaceholderCursor:
def _output_number_converter(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
def _output_type_handler(cursor, name, defaultType, length, precision, scale):
"""
......@@ -421,7 +429,7 @@ class FormatStylePlaceholderCursor:
elif precision > 0:
# NUMBER(p,s) column: decimal-precision fixed point.
# This comes from IntegerField and DecimalField columns.
outconverter = int if scale == 0 else decimal.Decimal
outconverter = FormatStylePlaceholderCursor._get_decimal_converter(precision, scale)
else:
# No type information. This normally comes from a
# mathematical expression in the SELECT list. Guess int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment