From: Michael Trier Date: Sat, 3 Jan 2009 20:07:17 +0000 (+0000) Subject: Corrected an issue on mssql where Numerics would not accept an int. X-Git-Tag: rel_0_5_0~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=770f603afb09f9586810e6a73351d13d1f73f585;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Corrected an issue on mssql where Numerics would not accept an int. --- diff --git a/CHANGES b/CHANGES index 0b63ab8883..e8d6664209 100644 --- 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 diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 0904d7b90a..e14732745f 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -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) diff --git a/test/dialect/mssql.py b/test/dialect/mssql.py index e6422a87a1..98040942db 100755 --- a/test/dialect/mssql.py +++ b/test/dialect/mssql.py @@ -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):