Comment metadata can be stored in two ways.
The first is that you can create two tables named C<table_comments> and
-C<column_comments> respectively. They both need to have columns named
-C<table_name> and C<comment_text>. The second one needs to have a column
-named C<column_name>. Then data stored in these tables will be used as a
-source of metadata about tables and comments.
+C<column_comments> respectively. These tables must exist in the same database
+and schema as the tables they describe. They both need to have columns named
+C<table_name> and C<comment_text>. The second one needs to have a column named
+C<column_name>. Then data stored in these tables will be used as a source of
+metadata about tables and comments.
(If you wish you can change the name of these tables with the parameters
L</table_comments_table> and L</column_comments_table>.)
The table to look for comments about tables in. By default C<table_comments>.
See L</generate_pod> for details.
+This must not be a fully qualified name, the table will be looked for in the
+same database and schema as the table whose comment is being retrieved.
+
=head2 column_comments_table
The table to look for comments about columns in. By default C<column_comments>.
See L</generate_pod> for details.
+This must not be a fully qualified name, the table will be looked for in the
+same database and schema as the table/column whose comment is being retrieved.
+
=head2 relationship_attrs
Hashref of attributes to pass to each generated relationship, listed
sub _table_comment {
my ($self, $table) = @_;
- my $comments_table = $self->table_comments_table;
+ my $comments_table = $table->clone;
+ $comments_table->name($self->table_comments_table);
my ($comment) = try { $self->dbh->selectrow_array(<<"EOF") };
SELECT comment_text
-FROM $comments_table
+FROM @{[ $comments_table->sql_name ]}
WHERE table_name = @{[ $self->dbh->quote($table->name) ]}
EOF
}
sub _column_comment {
- my ($self, $table, $column_counter, $column_name) = @_;
+ my ($self, $table, $column_number, $column_name) = @_;
- my $comments_table = $self->column_comments_table;
+ my $comments_table = $table->clone;
+ $comments_table->name($self->column_comments_table);
my ($comment) = try { $self->dbh->selectrow_array(<<"EOF") };
SELECT comment_text
-FROM $comments_table
+FROM @{[ $comments_table->sql_name ]}
WHERE table_name = @{[ $self->dbh->quote($table->name) ]}
AND column_name = @{[ $self->dbh->quote($column_name) ]}
EOF