my $col_name = $info->{COLUMN_NAME};
$col_name =~ s/^\"(.*)\"$/$1/;
- if ($self->_column_is_auto_increment($info)) {
- $column_info{is_auto_increment} = 1;
- }
+ my $extra_info = $self->_extra_column_info($info) || {};
- if (my $extra = $self->_column_extra_attr($info)) {
- $column_info{extra} = $extra;
- }
-
- $result{$col_name} = \%column_info;
+ $result{$col_name} = { %column_info, %$extra_info };
}
$sth->finish;
};
$column_info{size} = $2;
}
- if ($self->_column_is_auto_increment($table, $columns[$i], $sth, $i)) {
- $column_info{is_auto_increment} = 1;
- }
+ my $extra_info = $self->_extra_column_info($table, $columns[$i], $sth, $i) || {};
- if (my $extra = $self->_column_extra_attr($table, $columns[$i], $sth, $i)) {
- $column_info{extra} = $extra;
- }
-
- $result{$columns[$i]} = \%column_info;
+ $result{$columns[$i]} = { %column_info, %$extra_info };
}
$sth->finish;
return \%result;
}
-# Override this in vendor class to return whether a column is
-# auto-incremented
-sub _column_is_auto_increment {}
-
-# Override this in vendor class to return any "extra" column attributes
-sub _column_extra_attr {}
+# Override this in vendor class to return any additional column
+# attributes
+sub _extra_column_info {}
=head1 SEE ALSO
return \@uniqs;
}
-sub _column_is_auto_increment {
+sub _extra_column_info {
my ($self, $info) = @_;
+ my %extra_info;
- return $info->{COLUMN_DEF} && $info->{COLUMN_DEF} =~ /\bnextval\(/i;
+ if ($info->{COLUMN_DEF} && $info->{COLUMN_DEF} =~ /\bnextval\(/i) {
+ $extra_info{is_auto_increment} = 1;
+ }
+
+ return \%extra_info;
}
=head1 SEE ALSO
return { rels => \@rels, uniqs => \@uniqs, auto_inc => \%auto_inc };
}
-sub _column_is_auto_increment {
+sub _extra_column_info {
my ($self, $table, $col_name, $sth, $col_num) = @_;
-
+ my %extra_info;
+
$self->{_sqlite_parse_data}->{$table} ||=
$self->_sqlite_parse_table($table);
- return $self->{_sqlite_parse_data}->{$table}->{auto_inc}->{$col_name};
+ if ($self->{_sqlite_parse_data}->{$table}->{auto_inc}->{$col_name}) {
+ $extra_info{is_auto_increment} = 1;
+ }
+
+ return \%extra_info;
}
sub _table_fk_info {
return \@uniqs;
}
-sub _column_is_auto_increment {
+sub _extra_column_info {
my ($self, $info) = @_;
+ my %extra_info;
- return $info->{mysql_is_auto_increment};
-}
-
-sub _column_extra_attr {
- my ($self, $info) = @_;
-
- my $extra_attr;
+ if ($info->{mysql_is_auto_increment}) {
+ $extra_info{is_auto_increment} = 1
+ }
if ($info->{mysql_type_name} =~ /\bunsigned\b/i) {
- $extra_attr->{unsigned} = 1;
+ $extra_info{extra} = { unsigned => 1 };
}
- return $extra_attr;
+ return \%extra_info;
}
=head1 SEE ALSO