From: D. Ilmari Mannsåker Date: Mon, 8 Jul 2013 13:19:27 +0000 (+0100) Subject: Fix ordering issues in Pg loader X-Git-Tag: 0.07036~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9fc706c1a741067e6303a5fa146854da3aad7b88;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Fix ordering issues in Pg loader - Order foreign keys by name - Order enum values by explicit order column or OID if unavailable --- diff --git a/Changes b/Changes index 90855b5..ad43b00 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader - Fix stray comma in Pg on_delete/on_update => CASCADE (RT#84706) - Fix MySQL enums with empty strings and leading/trailing quotes (RT#86091) - Fix "table" parameter in col_accessor_map callback (RT#84050) + - Fix ordering issues in Pg loader 0.07035 2013-02-26 - Release 0.07034_01 with a stable version number. 0.07034 is diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 2ed553d..185532b 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -95,7 +95,7 @@ EOF }; } - return [ values %rels ]; + return [ map { $rels{$_} } sort keys %rels ]; } @@ -293,12 +293,14 @@ EOF if ($typetype && $typetype eq 'e') { # The following will extract a list of allowed values for the # enum. + my $order_column = $self->dbh->{pg_server_version} >= 90100 ? 'enumsortorder' : 'oid'; my $typevalues = $self->dbh ->selectall_arrayref(<{data_type}); SELECT e.enumlabel FROM pg_catalog.pg_enum e JOIN pg_catalog.pg_type t ON t.oid = e.enumtypid WHERE t.typname = ? +ORDER BY e.$order_column EOF $info->{extra}{list} = [ map { $_->[0] } @$typevalues ];