]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
mssql: modified table reflection code to use only kwargs when constructing coldefs.
authorRick Morrison <rickmorrison@gmail.com>
Fri, 23 Jan 2009 00:53:32 +0000 (00:53 +0000)
committerRick Morrison <rickmorrison@gmail.com>
Fri, 23 Jan 2009 00:53:32 +0000 (00:53 +0000)
CHANGES
lib/sqlalchemy/databases/mssql.py

diff --git a/CHANGES b/CHANGES
index 865e884889d985e4d191e55739b3f427e4d2e505..dc931ad478460966833f78450a92fec45313eaf5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -46,6 +46,9 @@ CHANGES
 
     - Really fixing the decimal handling this time. [ticket:1282].
 
+    - Modified table reflection code to use only kwargs when 
+      constructing tables. [Ticket:1289]
+
 0.5.1
 ========
 
index ddd13067943f9d28a0f744754277f8d7cdbcb425..ae36125130ee156887798edffb3087fea733c85c 100644 (file)
@@ -1148,32 +1148,28 @@ class MSSQLDialect(default.DefaultDialect):
             if include_columns and name not in include_columns:
                 continue
 
-            args = []
-            for a in (charlen, numericprec, numericscale):
-                if a is not None:
-                    args.append(a)
             coltype = self.ischema_names.get(type, None)
 
             kwargs = {}
             if coltype in (MSString, MSChar, MSNVarchar, MSNChar, MSText, MSNText):
+                kwargs['length'] = charlen
                 if collation:
-                    kwargs.update(collation=collation)
+                    kwargs['collation'] = collation
+                if coltype == MSText or (coltype in (MSString, MSNVarchar) and charlen == -1):
+                    kwargs.pop('length')
 
-            if coltype == MSText or (coltype == MSString and charlen == -1):
-                coltype = MSText(**kwargs)
-            else:
-                if coltype is None:
-                    util.warn("Did not recognize type '%s' of column '%s'" %
-                              (type, name))
-                    coltype = sqltypes.NULLTYPE
-
-                elif coltype in (MSNVarchar,) and charlen == -1:
-                    args[0] = None
-                coltype = coltype(*args, **kwargs)
+            if coltype in (MSNumeric,):   # TODO: include MSMoney?
+                kwargs['scale'] = numericscale
+                kwargs['precision'] = numericprec
+
+            if coltype is None:
+                util.warn("Did not recognize type '%s' of column '%s'" % (type, name))
+                coltype = sqltypes.NULLTYPE
+
+            coltype = coltype(**kwargs)
             colargs = []
             if default is not None:
                 colargs.append(schema.DefaultClause(sql.text(default)))
-
             table.append_column(schema.Column(name, coltype, nullable=nullable, autoincrement=False, *colargs))
 
         if not found_table: