to convert floats to Decimal from a DBAPI that returns floats.
This includes SQLite, Oracle, Sybase, MS-SQL.
[ticket:1759]
render inside of column expressions already assigned a label.
[ticket:1747]
+ - the Numeric type raises an *enormous* warning when expected
+ to convert floats to Decimal from a DBAPI that returns floats.
+ This includes SQLite, Oracle, Sybase, MS-SQL.
+ [ticket:1759]
+
- postgresql
- The psycopg2 dialect will log NOTICE messages via the
"sqlalchemy.dialects.postgresql" logger name.
class OracleDialect_cx_oracle(OracleDialect):
execution_ctx_cls = OracleExecutionContext_cx_oracle
statement_compiler = OracleCompiler_cx_oracle
+
driver = "cx_oracle"
colspecs = colspecs = {
# we're a "numeric", DBAPI will give us Decimal directly
return None
else:
+ util.warn("Dialect %s+%s does *not* support Decimal objects natively, "
+ "and SQLAlchemy must convert from floating point - "
+ "rounding errors and other issues may occur. "
+ "Please consider storing Decimal numbers as strings or "
+ "integers on this platform for lossless storage." %
+ (dialect.name, dialect.driver))
+
# we're a "numeric", DBAPI returns floats, convert.
if self.scale is not None:
return processors.to_decimal_processor_factory(_python_Decimal, self.scale)
:param precision: the numeric precision for use in DDL ``CREATE TABLE``.
:param asdecimal: the same flag as that of :class:`Numeric`, but
- defaults to ``False``.
+ defaults to ``False``. Note that setting this flag to ``True``
+ results in floating point conversion.
"""
self.precision = precision
def test_out_params(self):
result = testing.db.execute(text("begin foo(:x_in, :x_out, :y_out, :z_out); end;",
bindparams=[
- bindparam('x_in', Numeric),
+ bindparam('x_in', Float),
outparam('x_out', Integer),
- outparam('y_out', Numeric),
+ outparam('y_out', Float),
outparam('z_out', String)]),
x_in=5)
eq_(
finally:
metadata.drop_all()
+ @testing.emits_warning(r".*does \*not\* support Decimal objects natively")
def test_numerics(self):
m = MetaData(testing.db)
t1 = Table('t1', m,
def teardown(self):
metadata.drop_all()
+ @testing.emits_warning(r".*does \*not\* support Decimal objects natively")
def _do_test(self, type_, input_, output, filter_ = None):
t = Table('t', metadata, Column('x', type_))
t.create()
if filter_:
result = set(filter_(x) for x in result)
output = set(filter_(x) for x in output)
- print result
- print output
+ #print result
+ #print output
eq_(result, output)
-
+
def test_numeric_as_decimal(self):
self._do_test(
Numeric(precision=8, scale=4),