class PyODBCNumeric(sqltypes.Numeric):
"""Turns Decimals with adjusted() < -6 into floats, > 7 into strings"""
+ convert_large_decimals_to_string = False
+
def bind_processor(self, dialect):
super_process = super(PyODBCNumeric, self).bind_processor(dialect)
if value.adjusted() < -6:
return processors.to_float(value)
- elif value.adjusted() > 7:
+ elif self.convert_large_decimals_to_string and \
+ value.adjusted() > 7:
return self._large_dec_to_string(value)
if super_process:
from sqlalchemy import types as sqltypes, util
class _MSNumeric_pyodbc(PyODBCNumeric):
- pass
+ convert_large_decimals_to_string = True
+
class MSExecutionContext_pyodbc(MSExecutionContext):
_embedded_scope_identity = False
from sqlalchemy import types as sqltypes, util
class _SybNumeric_pyodbc(PyODBCNumeric):
- pass
+ convert_large_decimals_to_string = False
class SybaseExecutionContext_pyodbc(SybaseExecutionContext):
def set_ddl_autocommit(self, connection, value):
@testing.fails_on('sqlite', 'TODO')
@testing.fails_on('oracle', 'TODO')
- @testing.fails_on('sybase', 'TODO')
+ @testing.fails_on('postgresql+pg8000', 'TODO')
def test_many_significant_digits(self):
numbers = set([
decimal.Decimal("31943874831932418390.01"),
+ decimal.Decimal("319438950232418390.273596"),
])
self._do_test(
- Numeric(precision=25, scale=2),
+ Numeric(precision=26, scale=6),
numbers,
numbers
)