From: Michael Trier Date: Sun, 28 Dec 2008 17:38:26 +0000 (+0000) Subject: Corrected reflection issue in mssql where include_columns doesn't include the PK. X-Git-Tag: rel_0_5_0~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a848e2ac4719ef8c1fdedd8ee1dd57daa18969b2;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Corrected reflection issue in mssql where include_columns doesn't include the PK. --- 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