X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSetColumn.pm;h=68cc4e0c795f8c765a5e9135da4ef67c7e2bd347;hb=5d62876f5fe86bc1b3a11a571074164bcce27e7b;hp=876a3c1358ea3604d118084466ca693cd115327e;hpb=6b051e1428d7d5b5b5c8c02874266e76546758f3;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index 876a3c1..68cc4e0 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; } @@ -173,8 +175,13 @@ value. Produces the following SQL: sub func { my ($self,$function) = @_; - my ($row) = $self->{_parent_resultset}->search(undef, {select => {$function => $self->{_column}}, as => [$self->{_column}]})->cursor->next; - return $row; + my $cursor = $self->{_parent_resultset}->search(undef, {select => {$function => $self->{_column}}, as => [$self->{_column}]})->cursor; + + if( wantarray ) { + return map { $_->[ 0 ] } $cursor->all; + } + + return ( $cursor->next )[ 0 ]; } 1;