From: Matt S Trout Date: Thu, 21 Mar 2013 03:01:32 +0000 (+0000) Subject: default AS for fields if subquery expected X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=64bcb63f34ea8b6fb529c4486eaefbedbc98ef32;p=dbsrgits%2FDBIx-Class-Historic.git default AS for fields if subquery expected --- diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index 53bead8..cd25450 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -147,9 +147,7 @@ sub select { my %slice_stability = $self->renderer->slice_stability; - my $stability = $slice_stability{$offset ? 'offset' : 'limit'}; - - if ($stability) { + if (my $stability = $slice_stability{$offset ? 'offset' : 'limit'}) { my $source = $rs_attrs->{_rsroot_rsrc}; unless ( $final_attrs{order_is_stable} @@ -178,6 +176,20 @@ limit ' } } } + + } + + my %slice_subquery = $self->renderer->slice_subquery; + + if (my $subquery = $slice_subquery{$offset ? 'offset' : 'limit'}) { + $fields = [ map { + my $f = $fields->[$_]; + if (ref $f) { + $f = { '' => $f } unless ref($f) eq 'HASH'; + $f->{-as} ||= $final_attrs{as}[$_]; + } + $f; + } 0 .. $#$fields ]; } my ($sql, @bind) = $self->next::method ($table, $fields, $where, $final_attrs{order_by}, \%final_attrs );