[Bast-commits] r3152 -
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader
blblack at dev.catalyst.perl.org
blblack at dev.catalyst.perl.org
Thu Mar 29 15:11:00 GMT 2007
Author: blblack
Date: 2007-03-29 15:11:00 +0100 (Thu, 29 Mar 2007)
New Revision: 3152
Modified:
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm
Log:
import latest changes to DBIC::Storage::DBI to-be-deprecated columns_info_for to our variant
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 2007-03-29 13:45:05 UTC (rev 3151)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm 2007-03-29 14:11:00 UTC (rev 3152)
@@ -197,18 +197,12 @@
$table = $self->db_schema . $self->{_namesep} . $table;
}
my %result;
- my $sth = $dbh->prepare("SELECT * FROM $table WHERE 1=0");
+ my $sth = $dbh->prepare($self->schema->storage->sql_maker->select($table, undef, \'1 = 0'));
$sth->execute;
my @columns = @{$sth->{NAME_lc}};
for my $i ( 0 .. $#columns ){
my %column_info;
- my $type_num = $sth->{TYPE}->[$i];
- my $type_name;
- if(defined $type_num && $dbh->can('type_info')) {
- my $type_info = $dbh->type_info($type_num);
- $type_name = $type_info->{TYPE_NAME} if $type_info;
- }
- $column_info{data_type} = $type_name ? $type_name : $type_num;
+ $column_info{data_type} = $sth->{TYPE}->[$i];
$column_info{size} = $sth->{PRECISION}->[$i];
$column_info{is_nullable} = $sth->{NULLABLE}->[$i] ? 1 : 0;
@@ -219,11 +213,22 @@
$result{$columns[$i]} = \%column_info;
}
+ $sth->finish;
+ foreach my $col (keys %result) {
+ my $colinfo = $result{$col};
+ my $type_num = $colinfo->{data_type};
+ my $type_name;
+ if(defined $type_num && $dbh->can('type_info')) {
+ my $type_info = $dbh->type_info($type_num);
+ $type_name = $type_info->{TYPE_NAME} if $type_info;
+ $colinfo->{data_type} = $type_name if $type_name;
+ }
+ }
+
return \%result;
}
-
=head1 SEE ALSO
L<DBIx::Class::Schema::Loader>
More information about the Bast-commits
mailing list