sub _is_case_sensitive { 0 }
sub _custom_column_info {
- my ( $self, $info ) = @_;
+ my ( $self, $table_name, $column_name, $column_info ) = @_;
if( ref $self->custom_column_info eq 'CODE' ) {
- return $self->custom_column_info->($info);
+ return $self->custom_column_info->( $table_name, $column_name, $column_info );
}
return {};
}
sub _datetime_column_info {
- my ( $self, $info, $column_info) = @_;
+ my ( $self, $table_name, $column_name, $column_info ) = @_;
my $return = {};
- my $type = lc ( $info->{TYPE_NAME} );
-
+ my $type = lc ( $column_info->{data_type} );
if (
( defined $column_info->{inflate_datetime} and $column_info->{inflate_datetime} )
or ( defined $column_info->{inflate_date} and $column_info->{inflate_date} )
eval {
my $sth = $dbh->column_info( undef, $self->db_schema, $table, '%' );
while ( my $info = $sth->fetchrow_hashref() ){
- my %column_info;
- $column_info{data_type} = $info->{TYPE_NAME};
- $column_info{size} = $info->{COLUMN_SIZE};
- $column_info{is_nullable} = $info->{NULLABLE} ? 1 : 0;
- $column_info{default_value} = $info->{COLUMN_DEF};
+ my $column_info = {};
+ $column_info->{data_type} = $info->{TYPE_NAME};
+ $column_info->{size} = $info->{COLUMN_SIZE};
+ $column_info->{is_nullable} = $info->{NULLABLE} ? 1 : 0;
+ $column_info->{default_value} = $info->{COLUMN_DEF};
my $col_name = $info->{COLUMN_NAME};
$col_name =~ s/^\"(.*)\"$/$1/;
my $extra_info = $self->_extra_column_info($info) || {};
- my $custom_info = $self->_custom_column_info($info) || {};
- my $datetime_info = $self->_datetime_column_info($info,
- { %column_info, %$extra_info, %$custom_info }) || {};
- $result{$col_name} = { %column_info, %$extra_info, %$custom_info, %$datetime_info };
+ $column_info = { %$column_info, %$extra_info };
+
+ my $custom_info = $self->_custom_column_info( $table, $col_name, $column_info ) || {};
+ $column_info = { %$column_info, %$custom_info };
+
+ my $datetime_info = $self->_datetime_column_info( $table, $col_name, $column_info ) || {};
+ $column_info = { %$column_info, %$datetime_info };
+
+ $result{$col_name} = $column_info;
}
$sth->finish;
};
$sth->execute;
my @columns = @{$sth->{NAME_lc}};
for my $i ( 0 .. $#columns ){
- my %column_info;
- $column_info{data_type} = $sth->{TYPE}->[$i];
- $column_info{size} = $sth->{PRECISION}->[$i];
- $column_info{is_nullable} = $sth->{NULLABLE}->[$i] ? 1 : 0;
-
- if ($column_info{data_type} =~ m/^(.*?)\((.*?)\)$/) {
- $column_info{data_type} = $1;
- $column_info{size} = $2;
+ my $column_info = {};
+ $column_info->{data_type} = $sth->{TYPE}->[$i];
+ $column_info->{size} = $sth->{PRECISION}->[$i];
+ $column_info->{is_nullable} = $sth->{NULLABLE}->[$i] ? 1 : 0;
+
+ if ($column_info->{data_type} =~ m/^(.*?)\((.*?)\)$/) {
+ $column_info->{data_type} = $1;
+ $column_info->{size} = $2;
}
my $extra_info = $self->_extra_column_info($table, $columns[$i], $sth, $i) || {};
+ $column_info = { %$column_info, %$extra_info };
+
+ my $custom_info = $self->_custom_column_info( $table, $columns[$i], $column_info ) || {};
+ $column_info = { %$column_info, %$custom_info };
+
+ my $datetime_info = $self->_datetime_column_info( $table, $columns[$i], $column_info ) || {};
+ $column_info = { %$column_info, %$datetime_info };
- $result{$columns[$i]} = { %column_info, %$extra_info };
+ $result{$columns[$i]} = $column_info;
}
$sth->finish;
}
sub _custom_column_info {
- my $info = shift;
+ my ( $table_name, $column_name, $column_info ) = @_;
+ $table_name = lc ( $table_name );
+ $column_name = lc ( $column_name );
- if ( lc( $info->{TABLE_NAME} ) eq 'loader_test11'
- and lc( $info->{COLUMN_NAME} ) eq 'loader_test10'
+ if ( $table_name eq 'loader_test11'
+ and $column_name eq 'loader_test10'
){
return { is_numeric => 1 }
}
# Set inflate_datetime or inflate_date to check
# datetime_timezone and datetime_locale
- if ( lc( $info->{TABLE_NAME} ) eq 'loader_test36' ){
+ if ( $table_name eq 'loader_test36' ){
return { inflate_datetime => 1 } if
- ( lc( $info->{COLUMN_NAME} ) eq 'b_char_as_data' );
+ ( $column_name eq 'b_char_as_data' );
return { inflate_date => 1 } if
- ( lc( $info->{COLUMN_NAME} ) eq 'c_char_as_data' );
+ ( $column_name eq 'c_char_as_data' );
}
return;