Commits

Michael Trier committed a8651cf

Corrected an issue on mssql where Numerics would not accept an int.

Comments (0)

Files changed (3)

       new doc section "Custom Comparators".
     
 - mssql
+    - Corrected an issue with Numerics to accept an int.
+
     - Mapped ``char_length`` to the ``LEN()`` function.
 
     - If an ``INSERT`` includes a subselect the ``INSERT`` is

lib/sqlalchemy/databases/mssql.py

   does **not** work around
 
 """
-import datetime, inspect, operator, re, sys, urllib
+import datetime, decimal, inspect, operator, re, sys, urllib
 
 from sqlalchemy import sql, schema, exc, util
 from sqlalchemy.sql import compiler, expression, operators as sqlops, functions as sql_functions
                 # Not sure that this exception is needed
                 return value
             else:
-                if not isinstance(value, float) and value._exp < -6:
+                # FIXME: this will not correct a situation where a float
+                # gets converted to e-notation.
+                if isinstance(value, decimal.Decimal) and value._exp < -6:
                     value = ((value < 0 and '-' or '')
                         + '0.'
                         + '0' * -(value._exp+1)

test/dialect/mssql.py

             numeric_table.insert().execute(numericcol=Decimal('1E-6'))
             numeric_table.insert().execute(numericcol=Decimal('1E-7'))
             numeric_table.insert().execute(numericcol=Decimal('1E-8'))
-        except:
-            assert False
+            numeric_table.insert().execute(numericcol=10000)
+        except Exception, e:
+            raise e
 
 
 class TypesTest2(TestBase, AssertsExecutionResults):