From: Brendan Byrd Date: Fri, 6 Jan 2012 23:30:42 +0000 (-0500) Subject: Add support for REMARKS in *_info to use for *_comments X-Git-Tag: 0.07017~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ffed88caa6bfe0053af34e8e7f64ec6782257a8;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Add support for REMARKS in *_info to use for *_comments --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index 9a46207..191c1d0 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -333,6 +333,14 @@ FROM @{[ $comments_table->sql_name ]} WHERE table_name = @{[ $self->dbh->quote($table->name) ]} EOF + # Failback: try the REMARKS column on table_info + my $dbh = $self->dbh; + if (!$comment && $dbh->can('table_info')) { + my $sth = $self->_dbh_table_info( $dbh, undef, $table->schema, $table->name ); + my $info = $sth->fetchrow_hashref(); + $comment = $info->{REMARKS}; + } + return $comment; } @@ -348,7 +356,15 @@ FROM @{[ $comments_table->sql_name ]} WHERE table_name = @{[ $self->dbh->quote($table->name) ]} AND column_name = @{[ $self->dbh->quote($column_name) ]} EOF - + + # Failback: try the REMARKS column on column_info + my $dbh = $self->dbh; + if (!$comment && $dbh->can('column_info')) { + my $sth = $self->_dbh_column_info( $dbh, undef, $table->schema, $table->name, $column_name ); + my $info = $sth->fetchrow_hashref(); + $comment = $info->{REMARKS}; + } + return $comment; } @@ -516,6 +532,13 @@ sub _dbh_type_info_type_name { # do not use this, override _columns_info_for instead sub _extra_column_info {} +# override to mask warnings if needed +sub _dbh_table_info { + my ($self, $dbh) = (shift, shift); + + return $dbh->table_info(@_); +} + # override to mask warnings if needed (see mysql) sub _dbh_column_info { my ($self, $dbh) = (shift, shift);