Revision history for Perl extension DBIx::Class::Schema::Loader
+ - Added support for PostgreSQL enum types
- Added table/column comment support for Oracle
- Fix missing require (RT#62072)
elsif (lc($data_type) eq 'character') {
$info->{data_type} = 'char';
}
+ else {
+ my ($typetype) = $self->schema->storage->dbh
+ ->selectrow_array(<<EOF, {}, $data_type);
+SELECT typtype
+FROM pg_catalog.pg_type
+WHERE typname = ?
+EOF
+ if ($typetype eq 'e') {
+ $info->{data_type} = 'enum';
+ }
+ }
+
# process SERIAL columns
if (ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } =~ /\bnextval\(['"]([.\w]+)/i) {
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(<<EOF, {}, $info->{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) {
+ $extra_info{extra}{list} = [ map { $_->[0] } @$typevalues ];
+ }
+
+ return \%extra_info;
+}
+
+
=head1 SEE ALSO
L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
# Blob Types
bytea => { data_type => 'bytea' },
+
+ # Enum Types
+ pg_loader_test_enum => { data_type => 'enum', extra => { list => [ qw/foo bar baz/] }, size => 4 },
},
+ pre_create => [
+ q{
+ CREATE TYPE pg_loader_test_enum AS ENUM (
+ 'foo', 'bar', 'baz'
+ )
+ },
+ ],
extra => {
create => [
q{
],
pre_drop_ddl => [
'DROP SCHEMA dbicsl_test CASCADE',
+ 'DROP TYPE pg_loader_test_enum',
],
drop => [ qw/ pg_loader_test1 pg_loader_test2 / ],
count => 4,
my $dbh = $self->dbconnect(1);
+ $dbh->do($_) for @{ $self->{pre_create} || [] };
+
$dbh->do($_) foreach (@statements);
$dbh->do($_) foreach (@{ $self->{data_type_tests}{ddl} || [] });