From: Matt S Trout Date: Mon, 13 Feb 2006 17:19:01 +0000 (+0000) Subject: fixes for columns_info_for stuff from zby X-Git-Tag: v0.05005~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5afa2a15f7124d71a4349f4d8c66c766e0ad72ec;p=dbsrgits%2FDBIx-Class.git fixes for columns_info_for stuff from zby --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index eff072b..28f931f 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -40,6 +40,7 @@ sub new { $new->{_columns} = { %{$new->{_columns}||{}} }; $new->{_relationships} = { %{$new->{_relationships}||{}} }; $new->{name} ||= "!!NAME NOT SET!!"; + $new->{_columns_info_loaded} ||= 0; return $new; } @@ -107,8 +108,11 @@ sub column_info { my ($self, $column) = @_; $self->throw_exception("No such column $column") unless exists $self->_columns->{$column}; - if ( (! $self->_columns->{$column}->{data_type}) + #warn $self->{_columns_info_loaded}, "\n"; + if ( ! $self->_columns->{$column}->{data_type} + && ! $self->{_columns_info_loaded} && $self->schema && $self->storage() ){ + $self->{_columns_info_loaded}++; my $info; ############ eval for the case of storage without table eval{ diff --git a/t/run/01core.tl b/t/run/01core.tl index 412ac8f..34c9b9c 100644 --- a/t/run/01core.tl +++ b/t/run/01core.tl @@ -1,7 +1,7 @@ sub run_tests { my $schema = shift; -plan tests => 38; +plan tests => 39; my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); @@ -152,6 +152,9 @@ $schema->source("Artist")->{_columns}{'artistid'} = {}; my $typeinfo = $schema->source("Artist")->column_info('artistid'); is($typeinfo->{data_type}, 'INTEGER', 'column_info ok'); +$schema->source("Artist")->column_info('artistid'); +ok($schema->source("Artist")->{_columns_info_loaded} == 1, 'Columns info flag set'); + } 1;