summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/oracle
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-12-11 17:44:46 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-12-11 17:44:46 -0500
commitc691b4cbdf7424964f49ac2fd05057514e5856a3 (patch)
treea4d62e1d5c0e63c90fd1b5ce125928d7a86852c6 /lib/sqlalchemy/dialects/oracle
parentb88c54f95be3e3bc2e0923181d56862fa3fda9fa (diff)
downloadsqlalchemy-c691b4cbdf7424964f49ac2fd05057514e5856a3.tar.gz
- support for cdecimal
- add --with-cdecimal flag to tests, monkeypatches cdecimal in - fix mssql/pyodbc.py to not use private '_int' accessor in decimal conversion routines - pyodbc version 2.1.8 is needed for cdecimal in any case as previous versions also called '_int', 2.1.8 adds the same string logic as our own dialect, so that logic is skipped for modern pyodbc version - make the imports for "Decimal" consistent across the whole lib. not sure yet how we should be importing "Decimal" or what the best way forward is that would allow a clean user-invoked swap of cdecimal; for now, added docs suggesting a global monkeypatch - the two decimal libs are not compatible with each other so any chance of mixing produces serious issues. adding adapters to DBAPIs tedious and adds in-python overhead. suggestions welcome on how we should be doing Decimal/cdecimal.
Diffstat (limited to 'lib/sqlalchemy/dialects/oracle')
-rw-r--r--lib/sqlalchemy/dialects/oracle/cx_oracle.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
index 87a84e514..b7d663138 100644
--- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py
+++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
@@ -121,7 +121,7 @@ from sqlalchemy.engine import base
from sqlalchemy import types as sqltypes, util, exc, processors
from datetime import datetime
import random
-from decimal import Decimal
+from sqlalchemy.util.compat import decimal
import re
class _OracleNumeric(sqltypes.Numeric):
@@ -148,10 +148,10 @@ class _OracleNumeric(sqltypes.Numeric):
def to_decimal(value):
if value is None:
return None
- elif isinstance(value, Decimal):
+ elif isinstance(value, decimal.Decimal):
return value
else:
- return Decimal(fstring % value)
+ return decimal.Decimal(fstring % value)
return to_decimal
else:
if self.precision is None and self.scale is None:
@@ -569,15 +569,15 @@ class OracleDialect_cx_oracle(OracleDialect):
self._detect_decimal = \
lambda value: _detect_decimal(value.replace(char, '.'))
self._to_decimal = \
- lambda value: Decimal(value.replace(char, '.'))
+ lambda value: decimal.Decimal(value.replace(char, '.'))
def _detect_decimal(self, value):
if "." in value:
- return Decimal(value)
+ return decimal.Decimal(value)
else:
return int(value)
- _to_decimal = Decimal
+ _to_decimal = decimal.Decimal
def on_connect(self):
if self.cx_oracle_ver < (5,):