Merge 'resultsetcolumn_custom_columns' into 'trunk'
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSetColumn.pm
index 167cd02..7b0fee6 100644 (file)
@@ -40,10 +40,13 @@ sub new {
   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
 
+  # If $column can be found in the 'as' list of the parent resultset, use the
+  # corresponding element of its 'select' list (to keep any custom column
+  # definition set up with 'select' or '+select' attrs), otherwise use $column
+  # (to create a new column definition on-the-fly).
   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;