diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-01 16:57:02 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-01 16:57:02 -0400 |
| commit | 25db56bc0c1ee30fc0ad9166ac48de7dc8328762 (patch) | |
| tree | 019bf869c9876ced371ac6292df6b36ca1f0ebae /lib/sqlalchemy | |
| parent | 005d0453500c85fc8a6f15ce709251e2c5dae0f7 (diff) | |
| download | sqlalchemy-25db56bc0c1ee30fc0ad9166ac48de7dc8328762.tar.gz | |
- Oracle's "native decimal" metadata begins to return
ambiguous typing information about numerics
when columns are embedded in subqueries as well
as when ROWNUM is consulted with subqueries, as we
do for limit/offset. We've added these ambiguous
conditions to the cx_oracle "convert to Decimal()"
handler, so that we receive numerics as Decimal
in more cases instead of as floats. These are
then converted, if requested, into Integer
or Float, or otherwise kept as the lossless
Decimal [ticket:1840].
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/oracle/cx_oracle.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index dd32f3201..01ac1a685 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -86,10 +86,11 @@ class _OracleNumeric(sqltypes.Numeric): # we apply a connection output handler that # returns Decimal for positive precision + scale NUMBER # types + if dialect.supports_native_decimal: if self.asdecimal and self.scale is None: processors.to_decimal_processor_factory(Decimal) - elif not self.asdecimal and self.scale > 0: + elif not self.asdecimal: return processors.to_float else: return None @@ -465,9 +466,15 @@ class OracleDialect_cx_oracle(OracleDialect): cx_Oracle = self.dbapi def output_type_handler(cursor, name, defaultType, size, precision, scale): - # convert all NUMBER with precision + positive scale to Decimal. + # convert all NUMBER with precision + positive scale to Decimal, + # or zero precision and 0 or neg scale, indicates "don't know", # this effectively allows "native decimal" mode. - if defaultType == cx_Oracle.NUMBER and precision and scale > 0: + + if defaultType == cx_Oracle.NUMBER \ + and ( + (precision and scale > 0) or \ + (not precision and scale <= 0) + ): return cursor.var( cx_Oracle.STRING, 255, |
