[Bast-commits] r3983 - in
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader:
. DBI
ilmari at dev.catalyst.perl.org
ilmari at dev.catalyst.perl.org
Mon Jan 28 21:03:26 GMT 2008
Author: ilmari
Date: 2008-01-28 21:03:25 +0000 (Mon, 28 Jan 2008)
New Revision: 3983
Modified:
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
Log:
Merge _column_is_auto_increment() and _column_extra_attr() into
_extra_column_info() that gets merged into the column_info hash.
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm 2008-01-28 19:32:07 UTC (rev 3982)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm 2008-01-28 21:03:25 UTC (rev 3983)
@@ -95,10 +95,15 @@
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
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm 2008-01-28 19:32:07 UTC (rev 3982)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm 2008-01-28 21:03:25 UTC (rev 3983)
@@ -146,13 +146,18 @@
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 {
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm 2008-01-28 19:32:07 UTC (rev 3982)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm 2008-01-28 21:03:25 UTC (rev 3983)
@@ -121,21 +121,18 @@
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
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm 2008-01-28 19:32:07 UTC (rev 3982)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm 2008-01-28 21:03:25 UTC (rev 3983)
@@ -222,15 +222,9 @@
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;
};
@@ -255,15 +249,9 @@
$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;
@@ -281,13 +269,10 @@
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 additional column
+# attributes
+sub _extra_column_info {}
-# Override this in vendor class to return any "extra" column attributes
-sub _column_extra_attr {}
-
=head1 SEE ALSO
L<DBIx::Class::Schema::Loader>
More information about the Bast-commits
mailing list