PG. [ticket:2290]. Thanks to Ryan P. Kelly for
the patch.
+ - Fixed bug related to [ticket:2141] whereby the
+ same modified index behavior in PG 9 affected
+ primary key reflection on a renamed column.
+ [ticket:2291]. Also in 0.6.9.
+
- Reflection functions for Table, Sequence no longer
case insensitive. Names can be differ only in case
and will be correctly distinguished. [ticket:2256]
def get_primary_keys(self, connection, table_name, schema=None, **kw):
table_oid = self.get_table_oid(connection, table_name, schema,
info_cache=kw.get('info_cache'))
+
PK_SQL = """
- SELECT attname FROM pg_attribute
- WHERE attrelid = (
- SELECT indexrelid FROM pg_index i
- WHERE i.indrelid = :table_oid
- AND i.indisprimary = 't')
- ORDER BY attnum
+ SELECT a.attname
+ FROM
+ pg_class t
+ join pg_index ix on t.oid = ix.indrelid
+ join pg_attribute a
+ on t.oid=a.attrelid and a.attnum=ANY(ix.indkey)
+ WHERE
+ t.oid = :table_oid and
+ ix.indisprimary = 't'
+ ORDER BY
+ a.attnum
"""
t = sql.text(PK_SQL, typemap={'attname':sqltypes.Unicode})
c = connection.execute(t, table_oid=table_oid)