]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Corrected reflection issue in mssql where include_columns doesn't include the PK.
authorMichael Trier <mtrier@gmail.com>
Sun, 28 Dec 2008 17:38:26 +0000 (17:38 +0000)
committerMichael Trier <mtrier@gmail.com>
Sun, 28 Dec 2008 17:38:26 +0000 (17:38 +0000)
lib/sqlalchemy/databases/mssql.py

index 61f54a8ba3d5a79acd83f09bb0abff5ebcf5f037..0844745de06bcbf8f882ceeccb08cc806293750e 100644 (file)
@@ -1096,7 +1096,7 @@ class MSSQLDialect(default.DefaultDialect):
             if row is None:
                 break
             col_name, type_name = row[3], row[5]
-            if type_name.endswith("identity"):
+            if type_name.endswith("identity") and col_name in table.c:
                 ic = table.c[col_name]
                 ic.autoincrement = True
                 # setup a psuedo-sequence to represent the identity attribute - we interpret this at table.create() time as the identity attribute
@@ -1128,7 +1128,7 @@ class MSSQLDialect(default.DefaultDialect):
                                                                          C.c.table_schema == (table.schema or current_schema)))
         c = connection.execute(s)
         for row in c:
-            if 'PRIMARY' in row[TC.c.constraint_type.name]:
+            if 'PRIMARY' in row[TC.c.constraint_type.name] and row[0] in table.c:
                 table.primary_key.add(table.c[row[0]])
 
         # Foreign key constraints