X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FPg.pm;h=196cbdfb047654943ebe7c1daac4387d216e2fd3;hb=4e793de74348432fc7d185641bac24a47005e01e;hp=529be87ec2acd909eb28904b056760b9f9c2042a;hpb=b8ae4518518752d47392c07448d561e6cff155a8;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 529be87..196cbdf 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -9,7 +9,7 @@ use base qw/ use Carp::Clan qw/^DBIx::Class/; use mro 'c3'; -our $VERSION = '0.07002'; +our $VERSION = '0.07004'; =head1 NAME @@ -232,11 +232,27 @@ FROM pg_catalog.pg_type WHERE typname = ? EOF if ($typetype eq 'e') { + # The following will extract a list of allowed values for the + # enum. + my $typevalues = $self->schema->storage->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 = ? +EOF + + $info->{extra}{list} = [ map { $_->[0] } @$typevalues ]; + + # Store its original name in extra for SQLT to pick up. + $info->{extra}{custom_type_name} = $info->{data_type}; + $info->{data_type} = 'enum'; + + delete $info->{size}; } } - # process SERIAL columns if (ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } =~ /\bnextval\(['"]([.\w]+)/i) { $info->{is_auto_increment} = 1; @@ -257,30 +273,6 @@ EOF return $result; } -sub _extra_column_info { - my ($self, $table, $col, $info, $dbi_info) = @_; - my %extra_info; - - # The following will extract a list of allowed values if this - # is an enumerated type. Otherwise, no results and we do nothing. - my $typevalues = $self->schema->storage->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 = ? -EOF - - if (@$typevalues) { - # This is an enum type. Store its original name in extra for SQLT to pick up. - $extra_info{extra}{list} = [ map { $_->[0] } @$typevalues ]; - $extra_info{extra}{custom_type_name} = $info->{data_type}; - } - - return \%extra_info; -} - - =head1 SEE ALSO L, L,