X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FPg.pm;h=55732764cbfc3079f79388a6f7f2af3fae2d3018;hb=3b71e53bd47bd29213e8fe12b3f9a2d1a229b587;hp=ccf6690eb89833308e46e72ce558003110127166;hpb=c930f78be67718446858647b878b1e4c590538f3;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 ccf6690..5573276 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -7,9 +7,9 @@ use base qw/ DBIx::Class::Schema::Loader::DBI /; use Carp::Clan qw/^DBIx::Class/; -use Class::C3; +use mro 'c3'; -our $VERSION = '0.07000'; +our $VERSION = '0.07007'; =head1 NAME @@ -145,6 +145,7 @@ sub _columns_info_for { my $data_type = $info->{data_type}; # these types are fixed size + # XXX should this be a negative match? if ($data_type =~ /^(?:bigint|int8|bigserial|serial8|boolean|bool|box|bytea|cidr|circle|date|double precision|float8|inet|integer|int|int4|line|lseg|macaddr|money|path|point|polygon|real|float4|smallint|int2|serial|serial4|text)\z/i) { delete $info->{size}; @@ -223,9 +224,37 @@ EOF elsif (lc($data_type) eq 'character') { $info->{data_type} = 'char'; } + else { + my ($typetype) = $self->schema->storage->dbh + ->selectrow_array(<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) { + if (ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } =~ /\bnextval\(['"]([.\w]+)/i) { $info->{is_auto_increment} = 1; $info->{sequence} = $1; delete $info->{default_value};