mirror of
https://github.com/django/django.git
synced 2025-05-05 06:27:31 +00:00
Fixed #28138 -- Used output type handler instead of numbersAsStrings on Oracle cursor.
Thanks Tim Graham for the review.
This commit is contained in:
parent
f04a404917
commit
946775227c
@ -385,11 +385,24 @@ class FormatStylePlaceholderCursor:
|
|||||||
|
|
||||||
def __init__(self, connection):
|
def __init__(self, connection):
|
||||||
self.cursor = connection.cursor()
|
self.cursor = connection.cursor()
|
||||||
# Necessary to retrieve decimal values without rounding error.
|
self.cursor.outputtypehandler = self._output_type_handler
|
||||||
self.cursor.numbersAsStrings = True
|
|
||||||
# The default for cx_Oracle < 5.3 is 50.
|
# The default for cx_Oracle < 5.3 is 50.
|
||||||
self.cursor.arraysize = 100
|
self.cursor.arraysize = 100
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _output_type_handler(cursor, name, defaultType, length, precision, scale):
|
||||||
|
"""
|
||||||
|
Called for each db column fetched from cursors. Return numbers as
|
||||||
|
strings so that decimal values don't have rounding error.
|
||||||
|
"""
|
||||||
|
if defaultType == Database.NUMBER:
|
||||||
|
return cursor.var(
|
||||||
|
Database.STRING,
|
||||||
|
size=255,
|
||||||
|
arraysize=cursor.arraysize,
|
||||||
|
outconverter=str,
|
||||||
|
)
|
||||||
|
|
||||||
def _format_params(self, params):
|
def _format_params(self, params):
|
||||||
try:
|
try:
|
||||||
return {k: OracleParam(v, self, True) for k, v in params.items()}
|
return {k: OracleParam(v, self, True) for k, v in params.items()}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user