PostgreSQL multi-column primary keys reflected in wrong order

Issue #2531 resolved
Former user created an issue

The reflection query for primary keys on PostgreSQL returns the correct column names, but ordered as they appear in the table, which is not necessarily the way they are ordered in the key.

Attaching a patch with a test that exhibits the problem, and a new query that corrects it. The new query also drops the unnecessary join to pg_class, but adds a subquery unnesting the key order (I didn't find an obvious way to do this without the subquery). I doubt this is any slower, but I haven't measured.

Comments (9)

  1. Former user Account Deleted

    Sure. You didn't include the test though ... was that deliberate? Reattaching as a separate patch if you want it, with @testing.fails_if(('postgresql', '<', (8, 4))) added.

  2. Former user Account Deleted

    Well that was a nice bout of brain flatulence I just had. You did include the test. Please disregard. :)

  3. Log in to comment