From: Nigel Metheringham Date: Sun, 9 Nov 2008 01:46:46 +0000 (+0000) Subject: This version passes tests but is ugly X-Git-Tag: v0.08240~56^2~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4cb6deac70a84ef310b40174cf4ff566e513cabc;p=dbsrgits%2FDBIx-Class.git This version passes tests but is ugly --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 7764436..dbb6abf 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2078,8 +2078,25 @@ sub _resolved_attrs { my $alias = $attrs->{alias}; $attrs->{columns} ||= delete $attrs->{cols} if exists $attrs->{cols}; - $attrs->{columns} ||= [ $source->columns ] unless ( $attrs->{select} ); - if ( $attrs->{columns} ) { + if ( $attrs->{select} ) { + $attrs->{select} = + ( ref $attrs->{select} eq 'ARRAY' ) + ? [ @{ $attrs->{select} } ] + : [ $attrs->{select} ]; + $attrs->{as} = ( + $attrs->{as} + ? ( + ref $attrs->{as} eq 'ARRAY' + ? [ @{ $attrs->{as} } ] + : [ $attrs->{as} ] + ) + : [ + map { m/^\Q${alias}.\E(.+)$/ ? $1 : $_ } @{ $attrs->{select} } + ] + ); + } + else { + $attrs->{columns} ||= [ $source->columns ]; # if columns is set we overwrite select & as $attrs->{select} = []; @@ -2109,23 +2126,7 @@ sub _resolved_attrs { } delete $attrs->{columns}; } - else { - $attrs->{select} = - ( ref $attrs->{select} eq 'ARRAY' ) - ? [ @{ $attrs->{select} } ] - : [ $attrs->{select} ]; - $attrs->{as} = ( - $attrs->{as} - ? ( - ref $attrs->{as} eq 'ARRAY' - ? [ @{ $attrs->{as} } ] - : [ $attrs->{as} ] - ) - : [ - map { m/^\Q${alias}.\E(.+)$/ ? $1 : $_ } @{ $attrs->{select} } - ] - ); - } + my $adds; if ( $adds = delete $attrs->{include_columns} ) { $adds = [$adds] unless ref $adds eq 'ARRAY'; @@ -2376,12 +2377,15 @@ so you will need to manually quote things as appropriate.) =back -Shortcut to request a particular set of columns to be retrieved. Adds -C onto the start of any column without a C<.> in it and sets C as normal. (You may also -use the C attribute, as in earlier versions of DBIC.) +Shortcut to request a particular set of columns to be retrieved. Each +column spec may be a string (a table column name), or a hash (in which +case the key is the C value, and the value is used as the C from that, then auto-populates C from +C