- changed milestone to 0.7.9
PostgreSQL multi-column primary keys reflected in wrong order
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)
-
repo owner -
Account Deleted Patch against rel_0_7
-
Account Deleted Patch against default branch
-
Account Deleted Updated patches to apply cleanly after recent conflicting whitespace cleanup.
-
repo owner - changed status to resolved
had to put version detection in this with the old query as a fallback, as unnest() and generate_subscripts() are only in PG's docs for version 8.4 and forward.
thanks for the patches !
-
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. -
Account Deleted Patch against rel_0_7 adding a test
-
Account Deleted Well that was a nice bout of brain flatulence I just had. You did include the test. Please disregard. :)
-
repo owner - removed milestone
Removing milestone: 0.7.9 (automated comment)
- Log in to comment