since 0.7 doesn't respect the ".key" in a wider
range of scenarios.
+ .. change::
+ :tags: mssql, feature
+ :tickets: 2600
+
+ Support for reflection of the "name" of primary key
+ constraints added, courtesy Dave Moore.
+
.. changelog::
:version: 0.8.0b1
:released: October 30, 2012
C = ischema.key_constraints.alias('C')
# Primary key constraints
- s = sql.select([C.c.column_name, TC.c.constraint_type],
+ s = sql.select([C.c.column_name, TC.c.constraint_type, C.c.constraint_name],
sql.and_(TC.c.constraint_name == C.c.constraint_name,
TC.c.table_schema == C.c.table_schema,
C.c.table_name == tablename,
C.c.table_schema == owner)
)
c = connection.execute(s)
+ constraint_name = None
for row in c:
if 'PRIMARY' in row[TC.c.constraint_type.name]:
pkeys.append(row[0])
- return {'constrained_columns': pkeys, 'name': None}
+ if constraint_name is None:
+ constraint_name = row[C.c.constraint_name.name]
+ return {'constrained_columns': pkeys, 'name': constraint_name}
@reflection.cache
@_db_plus_owner
def reflects_pk_names(self):
"""Target driver reflects the name of primary key constraints."""
- return fails_on_everything_except('postgresql', 'oracle')
+ return fails_on_everything_except('postgresql', 'oracle', 'mssql')
@property
def python2(self):