summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-12-15 10:56:18 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2017-12-17 11:00:55 -0500
commita5d027ab665585f65581fdc6fd2bd00874d3c714 (patch)
tree45a2df5c0d2aceb584272d09cc1d9cbefd84722a /lib/sqlalchemy/dialects
parent19e13cf3d203b59ad285ab0193cb9fc53c4fcff2 (diff)
downloadsqlalchemy-a5d027ab665585f65581fdc6fd2bd00874d3c714.tar.gz
Open up all cx_Oracle numeric tests, finish infinity support
Added some additional rules to fully handle ``Decimal('Infinity')``, ``Decimal('-Infinity')`` values with cx_Oracle numerics when using ``asdecimal=True``. Allow remaining cx_Oracle numeric tests that were waiting for the refactor to be finished and forgot to get enabled. Change-Id: I1e2365176e34559c0230c84f800a7cfe0a034ed5 Fixes: #4064
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/oracle/cx_oracle.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
index 68ecce519..0288fe898 100644
--- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py
+++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
@@ -223,6 +223,8 @@ class _OracleNumeric(sqltypes.Numeric):
def process(value):
if isinstance(value, (int, float)):
return processor(value)
+ elif value is not None and value.is_infinite():
+ return float(value)
else:
return value
return process
@@ -242,7 +244,12 @@ class _OracleNumeric(sqltypes.Numeric):
outconverter = None
if precision:
if self.asdecimal:
- if is_cx_oracle_6:
+ if default_type == cx_Oracle.NATIVE_FLOAT:
+ # receiving float and doing Decimal after the fact
+ # allows for float("inf") to be handled
+ type_ = default_type
+ outconverter = decimal.Decimal
+ elif is_cx_oracle_6:
type_ = decimal.Decimal
else:
type_ = cx_Oracle.STRING
@@ -258,7 +265,10 @@ class _OracleNumeric(sqltypes.Numeric):
type_ = cx_Oracle.NATIVE_FLOAT
else:
if self.asdecimal:
- if is_cx_oracle_6:
+ if default_type == cx_Oracle.NATIVE_FLOAT:
+ type_ = default_type
+ outconverter = decimal.Decimal
+ elif is_cx_oracle_6:
type_ = decimal.Decimal
else:
type_ = cx_Oracle.STRING