From: Mike Bayer Date: Thu, 18 Mar 2010 19:44:12 +0000 (+0000) Subject: some weird numerictype coming back from pysybase, run through float() X-Git-Tag: rel_0_6beta2~29^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf4c5685e1a7fd37db1a0c3802333eac832f0780;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git some weird numerictype coming back from pysybase, run through float() --- diff --git a/lib/sqlalchemy/dialects/sybase/pysybase.py b/lib/sqlalchemy/dialects/sybase/pysybase.py index 8944465eec..6aad4e4cfa 100644 --- a/lib/sqlalchemy/dialects/sybase/pysybase.py +++ b/lib/sqlalchemy/dialects/sybase/pysybase.py @@ -21,10 +21,18 @@ kind at this time. """ +from sqlalchemy import types as sqltypes, processors from sqlalchemy.dialects.sybase.base import SybaseDialect, \ SybaseExecutionContext, SybaseSQLCompiler +class _SybNumeric(sqltypes.Numeric): + def result_processor(self, dialect, type_): + if not self.asdecimal: + return processors.to_float + else: + return sqltypes.Numeric.result_processor(self, dialect, type_) + class SybaseExecutionContext_pysybase(SybaseExecutionContext): def set_ddl_autocommit(self, dbapi_connection, value): @@ -52,6 +60,11 @@ class SybaseDialect_pysybase(SybaseDialect): execution_ctx_cls = SybaseExecutionContext_pysybase statement_compiler = SybaseSQLCompiler_pysybase + colspecs={ + sqltypes.Numeric:_SybNumeric, + sqltypes.Float:sqltypes.Float + } + @classmethod def dbapi(cls): import Sybase