From: Matt S Trout Date: Fri, 20 Apr 2012 03:20:25 +0000 (+0000) Subject: Variation of dq's d35a4e048 - sanify multiplying join prune X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=437a9cfaa7ef361284eee806578be7690a229ff8;p=dbsrgits%2FDBIx-Class-Historic.git Variation of dq's d35a4e048 - sanify multiplying join prune Use a private more descriptive attr name --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 4792391..2e6c783 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1885,7 +1885,10 @@ sub _rs_update_delete { # make a new $rs selecting only the PKs (that's all we really need for the subq) delete $attrs->{$_} for qw/select as collapse _related_results_construction/; $attrs->{columns} = [ map { "$attrs->{alias}.$_" } @$idcols ]; - $attrs->{group_by} = \ ''; # FIXME - this is an evil hack, it causes the optimiser to kick in and throw away the LEFT joins + + # this will be consumed by the pruner waaaaay down the stack + $attrs->{_force_prune_multiplying_joins} = 1; + my $subrs = (ref $self)->new($rsrc, $attrs); if (@$idcols == 1) { diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index a9f3bff..fd290f0 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -24,7 +24,7 @@ use namespace::clean; # sub _prune_unused_joins { my $self = shift; - my ($from, $select, $where, $attrs, $ignore_multiplication) = @_; + my ($from, $select, $where, $attrs) = @_; return $from unless $self->_use_join_optimizer; @@ -40,7 +40,7 @@ sub _prune_unused_joins { # a grouped set will not be affected by amount of rows. Thus any # {multiplying} joins can go delete $aliastypes->{multiplying} - if $ignore_multiplication or $attrs->{group_by}; + if $attrs->{_force_prune_multiplying_joins} or $attrs->{group_by}; my @newfrom = $from->[0]; # FROM head is always present @@ -175,7 +175,9 @@ sub _adjust_select_args_for_complex_prefetch { local $self->{_use_join_optimizer} = 1; # throw away multijoins since we def. do not care about those inside the subquery - my $inner_from = $self->_prune_unused_joins ($from, $inner_select, $where, $inner_attrs, 'ignore_multiplication'); + my $inner_from = $self->_prune_unused_joins ($from, $inner_select, $where, { + %$inner_attrs, _force_prune_multiplying_joins => 1 + }); my $inner_aliastypes = $self->_resolve_aliastypes_from_select_args( $inner_from, $inner_select, $where, $inner_attrs );