$attrs->{select} = [ map { m/\./ ? $_ : "${alias}.$_" } @cols ];
}
$attrs->{as} ||= [ map { m/^$alias\.(.*)$/ ? $1 : $_ } @{$attrs->{select}} ];
+ if (my $include = delete $attrs->{include_columns}) {
+ push(@{$attrs->{select}}, @$include);
+ push(@{$attrs->{as}}, map { m/([^\.]+)$/; $1; } @$include);
+ }
#use Data::Dumper; warn Dumper(@{$attrs}{qw/select as/});
$attrs->{from} ||= [ { $alias => $source->from } ];
if (my $join = delete $attrs->{join}) {
push(@{$attrs->{from}}, $source->resolve_join($p, $attrs->{alias}))
unless $seen{$p};
}
- my @cols = ();
- push @cols, $source->resolve_prefetch($p, $attrs->{alias});
+ my @prefetch = $source->resolve_prefetch($p, $attrs->{alias});
#die Dumper \@cols;
- push(@{$attrs->{select}}, @cols);
- push(@{$attrs->{as}}, @cols);
+ push(@{$attrs->{select}}, map { $_->[0] } @prefetch);
+ push(@{$attrs->{as}}, map { $_->[1] } @prefetch);
}
}
$query->{$self->{attrs}{alias}.'.'.$_} = delete $query->{$_};
}
#warn Dumper($query);
- return $self->search($query)->next;
+ return $self->search($query,$attrs)->next;
}
=head2 search_related
C<me.> onto the start of any column without a C<.> in it and sets C<select>
from that, then auto-populates C<as> from C<select> as normal.
+=head2 include_columns (arrayref)
+
+Shortcut to include additional columns in the returned results - for example
+
+ { include_columns => ['foo.name'], join => ['foo'] }
+
+would add a 'name' column to the information passed to object inflation
+
=head2 select (arrayref)
Indicates which columns should be selected from the storage. You can use