From: Norbert Buchmuller Date: Sun, 16 Nov 2008 02:18:11 +0000 (+0100) Subject: * Rewrote fetching the 'select' and 'as' values from the parent resultset to somethi... X-Git-Tag: v0.08240~237^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b6e85b48a493680d1f2ddf5fea93d432e2cc6eb1;p=dbsrgits%2FDBIx-Class.git * Rewrote fetching the 'select' and 'as' values from the parent resultset to something that's easier to read for everyone. --- diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index 5a5f26d..167cd02 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -39,11 +39,14 @@ sub new { my $new_parent_rs = $rs->search_rs; # we don't want to mess up the original, so clone it my $attrs = $new_parent_rs->_resolved_attrs; $new_parent_rs->{attrs}->{$_} = undef for qw(prefetch include_columns +select +as); # prefetch, include_columns, +select, +as cause additional columns to be fetched - my ($select, $as) = - map { defined $_ ? ($attrs->{select}->[$_], $attrs->{as}->[$_]) : ($column, $column) } - List::Util::first { ($attrs->{as} || [])->[$_] eq $column } - 0..$#{$attrs->{as} || []}; - my $new = bless { _select => $select, _as => $as, _parent_resultset => $new_parent_rs }, $class; + + my $as_list = $attrs->{as} || []; + my $select_list = $attrs->{select} || []; + my $as_index = List::Util::first { ($as_list->[$_] || "") eq $column } 0..$#$as_list; + + my $select = defined $as_index ? $select_list->[$as_index] : $column; + + my $new = bless { _select => $select, _as => $column, _parent_resultset => $new_parent_rs }, $class; $new->throw_exception("column must be supplied") unless $column; return $new; } @@ -250,23 +253,17 @@ sub throw_exception { } } -=head2 _resultset - -=over 4 - -=item Arguments: none - -=item Return Value: $resultset - -=back - - $year_col->_resultset->next - -Returns the underlying resultset. Creates it from the parent resultset if -necessary. - -=cut - +# _resultset +# +# Arguments: none +# +# Return Value: $resultset +# +# $year_col->_resultset->next +# +# Returns the underlying resultset. Creates it from the parent resultset if +# necessary. +# sub _resultset { my $self = shift;