diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-04-03 10:58:13 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-04-03 10:58:13 -0400 |
| commit | f432bc8fe15507653caff6f57e54d4bf6a78fbd7 (patch) | |
| tree | 10fbac3d6eafcb6b3ee813a057c0296a7b493163 /lib/sqlalchemy | |
| parent | f35132267e2245f44f44d94c25a3d2015c224ac2 (diff) | |
| download | sqlalchemy-f432bc8fe15507653caff6f57e54d4bf6a78fbd7.tar.gz | |
- 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]
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/oracle/cx_oracle.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/types.py | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index 91af6620b..c02f18886 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -345,6 +345,7 @@ class ReturningResultProxy(base.FullyBufferedResultProxy): class OracleDialect_cx_oracle(OracleDialect): execution_ctx_cls = OracleExecutionContext_cx_oracle statement_compiler = OracleCompiler_cx_oracle + driver = "cx_oracle" colspecs = colspecs = { diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 16cd57f26..dba75b36e 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -939,6 +939,13 @@ class Numeric(_DateAffinity, TypeEngine): # 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) @@ -976,7 +983,8 @@ class Float(Numeric): :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 |
