Revision history for Perl extension DBIx::Class::Schema::Loader
+ - Added table/column comment support for Oracle
- Fix missing require (RT#62072)
0.07002 2010-09-11 01:48:00
" $_: $s"
} sort keys %$attrs,
);
- if (my $comment = $self->__column_comment($self->{_class2table}{$class}, $col_counter)) {
+ if (my $comment = $self->__column_comment($self->{_class2table}{$class}, $col_counter, $name)) {
$self->_pod( $class, $comment );
}
}
return \@uniqs;
}
+sub _table_comment {
+ my ( $self, $table ) = @_;
+ my ($table_comment) = $self->schema->storage->dbh->selectrow_array(
+ q{
+ SELECT comments FROM all_tab_comments
+ WHERE owner = ?
+ AND table_name = ?
+ AND table_type = 'TABLE'
+ }, undef, $self->db_schema, $self->_uc($table)
+ );
+
+ return $table_comment
+}
+
+sub _column_comment {
+ my ( $self, $table, $column_number, $column_name ) = @_;
+ my ($column_comment) = $self->schema->storage->dbh->selectrow_array(
+ q{
+ SELECT comments FROM all_col_comments
+ WHERE owner = ?
+ AND table_name = ?
+ AND column_name = ?
+ }, undef, $self->db_schema, $self->_uc( $table ), $self->_uc( $column_name )
+ );
+ return $column_comment
+}
+
sub _table_pk_info {
my ($self, $table) = (shift, shift);
use dbixcsl_common_tests;
use Test::More;
use Test::Exception;
+use File::Slurp ();
my $dsn = $ENV{DBICTEST_ORA_DSN} || '';
my $user = $ENV{DBICTEST_ORA_USER} || '';
'urowid(3333)' => { data_type => 'urowid', size => 3333 },
},
extra => {
- count => 1,
+ create => [
+ q{
+ CREATE TABLE oracle_loader_test1 (
+ id NUMBER(11),
+ value VARCHAR2(100)
+ )
+ },
+ q{ COMMENT ON TABLE oracle_loader_test1 IS 'oracle_loader_test1 table comment' },
+ q{ COMMENT ON COLUMN oracle_loader_test1.value IS 'oracle_loader_test1.value column comment' },
+ ],
+ drop => [qw/oracle_loader_test1/],
+ count => 3,
run => sub {
my ($schema, $monikers, $classes) = @_;
skip 'not running common tests', 1;
}
}
+
+ SKIP: {
+ skip 'not running comment tests', 1 unless (my $class = $classes->{oracle_loader_test1});
+ my $filename = $schema->_loader->_get_dump_filename($class);
+ my $code = File::Slurp::slurp $filename;
+
+ like $code, qr/^=head1 NAME\n\n^$class - oracle_loader_test1 table comment\n\n^=cut\n/m,
+ 'table comment';
+
+ like $code, qr/^=head2 value\n\n(.+:.+\n)+\noracle_loader_test1\.value column comment\n\n/m,
+ 'column comment and attrs';
+ }
},
},
);