my ($table) = @_;
my $pcm = $self->pod_comment_mode;
my ($comment, $comment_overflows, $comment_in_name, $comment_in_desc);
- if ( $self->can('_table_comment') ) {
- $comment = $self->_table_comment($table);
- $comment_overflows = ($comment and length $comment > $self->pod_comment_spillover_length);
- $comment_in_name = ($pcm eq 'name' or ($pcm eq 'auto' and !$comment_overflows));
- $comment_in_desc = ($pcm eq 'description' or ($pcm eq 'auto' and $comment_overflows));
- }
+ $comment = $self->__table_comment($table);
+ $comment_overflows = ($comment and length $comment > $self->pod_comment_spillover_length);
+ $comment_in_name = ($pcm eq 'name' or ($pcm eq 'auto' and !$comment_overflows));
+ $comment_in_desc = ($pcm eq 'description' or ($pcm eq 'auto' and $comment_overflows));
$self->_pod( $class, "=head1 NAME" );
my $table_descr = $class;
$table_descr .= " - " . $comment if $comment and $comment_in_name;
} sort keys %$attrs,
);
- if( $self->can('_column_comment')
- and my $comment = $self->_column_comment( $self->{_class2table}{$class}, $col_counter)
- ) {
+ if (my $comment = $self->__column_comment($self->{_class2table}{$class}, $col_counter)) {
$self->_pod( $class, $comment );
}
}
}
}
+sub _filter_comment {
+ my ($self, $txt) = @_;
+
+ $txt = '' if not defined $txt;
+
+ $txt =~ s/(?:\015?\012|\015\012?)/\n/g;
+
+ return $txt;
+}
+
+sub __table_comment {
+ my $self = shift;
+
+ if (my $code = $self->can('_table_comment')) {
+ return $self->_filter_comment($self->$code(@_));
+ }
+
+ return '';
+}
+
+sub __column_comment {
+ my $self = shift;
+
+ if (my $code = $self->can('_column_comment')) {
+ return $self->_filter_comment($self->$code(@_));
+ }
+
+ return '';
+}
+
# Stores a POD documentation
sub _pod {
my ($self, $class, $stmt) = @_;
value VARCHAR(100)
)
},
- q{
- COMMENT ON TABLE pg_loader_test1 IS 'The Table'
+ qq{
+ COMMENT ON TABLE pg_loader_test1 IS 'The\15\12Table'
},
- q{
- COMMENT ON COLUMN pg_loader_test1.value IS 'The Column'
+ qq{
+ COMMENT ON COLUMN pg_loader_test1.value IS 'The\15\12Column'
},
q{
CREATE TABLE pg_loader_test2 (
my $code = slurp $filename;
- like $code, qr/^=head1 NAME\n\n^$class - The Table\n\n^=cut\n/m,
+ like $code, qr/^=head1 NAME\n\n^$class - The\nTable\n\n^=cut\n/m,
'table comment';
- like $code, qr/^=head2 value\n\n(.+:.+\n)+\nThe Column\n\n/m,
+ like $code, qr/^=head2 value\n\n(.+:.+\n)+\nThe\nColumn\n\n/m,
'column comment and attrs';
$class = $classes->{pg_loader_test2};