]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Corrected an issue on mssql where Numerics would not accept an int.
authorMichael Trier <mtrier@gmail.com>
Sat, 3 Jan 2009 20:07:17 +0000 (20:07 +0000)
committerMichael Trier <mtrier@gmail.com>
Sat, 3 Jan 2009 20:07:17 +0000 (20:07 +0000)
CHANGES
lib/sqlalchemy/databases/mssql.py
test/dialect/mssql.py

diff --git a/CHANGES b/CHANGES
index 0b63ab8883fa25dbe276431a053b49aaa3dd6d7d..e8d6664209cbc6b16b43c2754cf6d27c280bb140 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -289,6 +289,8 @@ CHANGES
       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
index 0904d7b90a8cd3a7d9e319e6d3cfacf06cdc6f24..e14732745fa3f69214f9300faa809f9f0a51e8a8 100644 (file)
@@ -220,7 +220,7 @@ Known Issues
   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
@@ -313,7 +313,9 @@ class MSNumeric(sqltypes.Numeric):
                 # 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)
index e6422a87a1126e01f09f340e9c1007adcde1a65e..98040942db7f76f10f5a3da3a9d3b147e0ff6631 100755 (executable)
@@ -498,8 +498,9 @@ class TypesTest(TestBase):
             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):