From: Luke Saunders Date: Mon, 9 Jul 2007 10:40:46 +0000 (+0000) Subject: updated changes. fixed ResultSetColumn w/prefetch problem X-Git-Tag: v0.08010~128 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3f6cc7e47e1084bdee20a01d1e05edc0dda4bc0c;p=dbsrgits%2FDBIx-Class.git updated changes. fixed ResultSetColumn w/prefetch problem --- diff --git a/Changes b/Changes index d258123..69facca 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,9 @@ Revision history for DBIx::Class with debian packaging - Patch to fix ? in data for NoBindVars (from Tom Hukins) - Restored mk_classaccessor method for compatibility + - Fixed group_by problem with oracle limit syntax + - Fixed attr merging problem + - Fixed $rs->get_column w/prefetch problem 0.08002 2007-06-20 06:10:00 - add scope guard to Row::insert to ensure rollback gets called diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index 876a3c1..f93cbdd 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -35,7 +35,9 @@ passed as params. Used internally by L. sub new { my ($class, $rs, $column) = @_; $class = ref $class if ref $class; - my $new = bless { _column => $column, _parent_resultset => $rs }, $class; + my $new_parent_rs = $rs->search_rs; # we don't want to mess up the original, so clone it + $new_parent_rs->{attrs}->{prefetch} = undef; # prefetch causes additional columns to be fetched + my $new = bless { _column => $column, _parent_resultset => $new_parent_rs }, $class; $new->throw_exception("column must be supplied") unless $column; return $new; } diff --git a/t/88result_set_column.t b/t/88result_set_column.t index 936a0a7..08828af 100644 --- a/t/88result_set_column.t +++ b/t/88result_set_column.t @@ -7,7 +7,7 @@ use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 8; +plan tests => 9; my $cd; my $rs = $cd = $schema->resultset("CD")->search({}); @@ -42,3 +42,8 @@ $psrs = $schema->resultset('CD')->search({}, ok(defined($psrs->get_column('count')), '+select/+as arrayref count'); ok(defined($psrs->get_column('addedtitle')), '+select/+as title'); +{ + my $rs = $schema->resultset("CD")->search({}, { prefetch => 'artist' }); + my $rsc = $rs->get_column('year'); + is( $rsc->{_parent_resultset}->{attrs}->{prefetch}, undef, 'prefetch wiped' ); +}