From: Justin Hunter Date: Sun, 26 Jul 2009 16:28:58 +0000 (-0700) Subject: separate out getting the column DATA_TYPE X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f76715bde34ae427d5099ea5ca4a5dd7b8b56fe6;p=dbsrgits%2FSQL-Translator-2.0-ish.git separate out getting the column DATA_TYPE --- diff --git a/lib/SQL/Translator/Parser/DBI.pm b/lib/SQL/Translator/Parser/DBI.pm index 21b3819..4ecf21a 100644 --- a/lib/SQL/Translator/Parser/DBI.pm +++ b/lib/SQL/Translator/Parser/DBI.pm @@ -43,7 +43,7 @@ role SQL::Translator::Parser::DBI { default => undef ); - method _subclass { + method _subclass { my $dbtype = $self->dbh->get_info($GetInfoType{SQL_DBMS_NAME}) || $self->dbh->{Driver}{Name}; my $class = __PACKAGE__ . '::'. $dbtype; @@ -55,6 +55,8 @@ role SQL::Translator::Parser::DBI { method _column_default_value(HashRef $column_info) { return $column_info->{COLUMN_DEF}; } + method _column_data_type(HashRef $column_info) { return $column_info->{DATA_TYPE}; } + method _add_tables(Schema $schema) { my $sth = $self->dbh->table_info($self->catalog_name, $self->schema_name, '%', "TABLE,VIEW,'LOCAL TEMPORARY','GLOBAL TEMPORARY'"); while (my $table_info = $sth->fetchrow_hashref) { @@ -81,7 +83,7 @@ role SQL::Translator::Parser::DBI { my $sth = $self->dbh->column_info($self->catalog_name, $self->schema_name, $table->name, '%'); while (my $column_info = $sth->fetchrow_hashref) { my $column = SQL::Translator::Object::Column->new({ name => $column_info->{COLUMN_NAME}, - data_type => $column_info->{DATA_TYPE}, + data_type => $self->_column_data_type($column_info), size => $column_info->{COLUMN_SIZE}, default_value => $self->_column_default_value($column_info), is_auto_increment => $self->_is_auto_increment($column_info), @@ -129,6 +131,8 @@ role SQL::Translator::Parser::DBI { method _add_indexes(Table $table) { my $index_info = $self->dbh->statistics_info($self->catalog_name, $self->schema_name, $table->name, 1, 0); + return unless defined $index_info; + my ($index_name, $index_type, @index_cols); while (my $index_col = $index_info->fetchrow_hashref) { $index_name = $index_col->{INDEX_NAME};