]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
some weird numerictype coming back from pysybase, run through float()
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 18 Mar 2010 19:44:12 +0000 (19:44 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 18 Mar 2010 19:44:12 +0000 (19:44 +0000)
lib/sqlalchemy/dialects/sybase/pysybase.py

index 8944465eecbbcd83912661fb114f31d045903f05..6aad4e4cfa3f81e93803bb1e7549865343329a9f 100644 (file)
@@ -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