]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
further numeric fixes
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 27 Feb 2010 20:10:03 +0000 (20:10 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 27 Feb 2010 20:10:03 +0000 (20:10 +0000)
lib/sqlalchemy/dialects/mssql/base.py

index dc767882b82286b459c362157e30b56f2c813f25..988088faedece8663d4f31d80f4796b4326120f3 100644 (file)
@@ -279,16 +279,22 @@ RESERVED_WORDS = set(
 class _MSNumeric(sqltypes.Numeric):
     def result_processor(self, dialect, coltype):
         if self.asdecimal:
-            if getattr(self, 'scale', None) is not None and dialect.supports_native_decimal:
+            # TODO: factor this down into the sqltypes.Numeric class,
+            # use dialect flags
+            if getattr(self, 'scale', None) is None:
+                # we're a "float".  return a default decimal factory
+                return processors.to_decimal_processor_factory(decimal.Decimal)
+            elif dialect.supports_native_decimal:
+                # we're a "numeric", DBAPI will give us Decimal directly
                 return None
             else:
-                return processors.to_decimal_processor_factory(decimal.Decimal)
+                # we're a "numeric", DBAPI returns floats, convert.
+                return processors.to_decimal_processor_factory(decimal.Decimal, self.scale)
         else:
             #XXX: if the DBAPI returns a float (this is likely, given the
             # processor when asdecimal is True), this should be a None
             # processor instead.
             return processors.to_float
-            return None
             
     def bind_processor(self, dialect):
         def process(value):