]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed MSSQL reflection bug which did not properly handle
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 16 Oct 2010 16:15:40 +0000 (12:15 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 16 Oct 2010 16:15:40 +0000 (12:15 -0400)
reflection of unknown types.  [ticket:1946]

CHANGES
lib/sqlalchemy/dialects/mssql/base.py
test/dialect/test_mssql.py

diff --git a/CHANGES b/CHANGES
index 2cf9a925462ee29a6db7eb4d68bcf244b854644f..a2e864bdac18fe18f6cf54d1f11b007e71d001c4 100644 (file)
--- 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 
index 95a5bf4c446b3dd0d0ed91a781bc2dcc510672cc..52b51a0ffa8af51d53087636646a96d8cc762619 100644 (file)
@@ -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,
index 7f34b980ab2aee6406b589cade0f89dc2126ac9a..c6d8d3f28de2667506923aa18f7b0f77e26d68ac 100644 (file)
@@ -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'