From a848e2ac4719ef8c1fdedd8ee1dd57daa18969b2 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Sun, 28 Dec 2008 17:38:26 +0000 Subject: [PATCH] Corrected reflection issue in mssql where include_columns doesn't include the PK. --- lib/sqlalchemy/databases/mssql.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 61f54a8ba3..0844745de0 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -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 -- 2.47.3