From: Mike Bayer Date: Sat, 16 Oct 2010 16:15:40 +0000 (-0400) Subject: - Fixed MSSQL reflection bug which did not properly handle X-Git-Tag: rel_0_6_5~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a714db53b351ef741585adeb35450354e2a96004;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed MSSQL reflection bug which did not properly handle reflection of unknown types. [ticket:1946] --- diff --git a/CHANGES b/CHANGES index 2cf9a92546..a2e864bdac 100644 --- a/CHANGES +++ b/CHANGES @@ -193,6 +193,10 @@ CHANGES 'echo', 'echo_pool', 'force' for 'convert_unicode', boolean values for 'use_native_unicode'. [ticket:1899] + +- mssql + - Fixed reflection bug which did not properly handle + reflection of unknown types. [ticket:1946] - informix - *Major* cleanup / modernization of the Informix diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 95a5bf4c44..52b51a0ffa 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1207,13 +1207,13 @@ class MSDialect(default.DefaultDialect): "Did not recognize type '%s' of column '%s'" % (type, name)) coltype = sqltypes.NULLTYPE + else: + if issubclass(coltype, sqltypes.Numeric) and \ + coltype is not MSReal: + kwargs['scale'] = numericscale + kwargs['precision'] = numericprec - if issubclass(coltype, sqltypes.Numeric) and \ - coltype is not MSReal: - kwargs['scale'] = numericscale - kwargs['precision'] = numericprec - - coltype = coltype(**kwargs) + coltype = coltype(**kwargs) cdict = { 'name' : name, 'type' : coltype, diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py index 7f34b980ab..c6d8d3f28d 100644 --- a/test/dialect/test_mssql.py +++ b/test/dialect/test_mssql.py @@ -444,8 +444,21 @@ class ReflectionTest(TestBase, ComparesTables): assert sequence.increment == 3 finally: table.drop() - - + + @testing.emits_warning("Did not recognize") + def test_skip_types(self): + meta = MetaData(testing.db) + testing.db.execute(""" + create table foo (id integer primary key, data xml) + """) + try: + t1 = Table('foo', meta, autoload=True) + assert isinstance(t1.c.id.type, Integer) + assert isinstance(t1.c.data.type, types.NullType) + finally: + testing.db.execute("drop table foo") + + class QueryUnicodeTest(TestBase): __only_on__ = 'mssql'