X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBIHacks.pm;h=c46b0e3c158bb5a8809e0f289d41f9eb191bf16b;hb=31a8aaaf104a710ae5b7671659e89c1ef62c84e8;hp=2d10e6c8847434ec5b576859ac4ac5990ace04ac;hpb=1a736efbe47845f6eeccc00059b37172cfc6e441;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index 2d10e6c..c46b0e3 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -14,6 +14,9 @@ use base 'DBIx::Class::Storage'; use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; +use List::Util 'first'; +use Scalar::Util 'blessed'; +use namespace::clean; # # This code will remove non-selecting/non-restricting joins from @@ -94,6 +97,8 @@ sub _adjust_select_args_for_complex_prefetch { } push @$inner_select, $sel; + + push @{$inner_attrs->{as}}, $attrs->{as}[$i]; } # construct the inner $from for the subquery @@ -103,10 +108,7 @@ sub _adjust_select_args_for_complex_prefetch { # if a multi-type join was needed in the subquery - add a group_by to simulate the # collapse in the subq $inner_attrs->{group_by} ||= $inner_select - if List::Util::first - { ! $_->[0]{-is_single} } - (@{$inner_from}[1 .. $#$inner_from]) - ; + if first { ! $_->[0]{-is_single} } (@{$inner_from}[1 .. $#$inner_from]); # generate the subquery my $subq = $self->_select_args_to_query ( @@ -238,10 +240,11 @@ sub _resolve_aliastypes_from_select_args { local $sql_maker->{quote_char} = "\x00"; # so that we can regex away # generate sql chunks + local $sql_maker->{having_bind}; # these are throw away results my $to_scan = { restricting => [ $sql_maker->_recurse_where ($where), - $sql_maker->_order_by({ + $sql_maker->_parse_rs_attrs ({ map { $_ => $attrs->{$_} } (qw/group_by having/) }), ], @@ -273,7 +276,6 @@ sub _resolve_aliastypes_from_select_args { $aliases_by_type->{$type}{$alias} = 1 if ($piece =~ $al_re); } } - } # now loop through unqualified column names, and try to locate them within @@ -308,7 +310,7 @@ sub _resolve_aliastypes_from_select_args { for my $type (keys %$aliases_by_type) { for my $alias (keys %{$aliases_by_type->{$type}}) { $aliases_by_type->{$type}{$_} = 1 - for (map { keys %$_ } @{ $alias_list->{$alias}{-join_path} || [] }); + for (map { values %$_ } @{ $alias_list->{$alias}{-join_path} || [] }); } } @@ -323,7 +325,7 @@ sub _resolve_ident_sources { # the reason this is so contrived is that $ident may be a {from} # structure, specifying multiple tables to join - if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) { + if ( blessed $ident && $ident->isa("DBIx::Class::ResultSource") ) { # this is compat mode for insert/update/delete which do not deal with aliases $alias2source->{me} = $ident; $rs_alias = 'me'; @@ -419,7 +421,7 @@ sub _resolve_column_info { # the top of the stack, and if not - make sure the chain is inner-joined down # to the root. # -sub _straight_join_to_node { +sub _inner_join_to_node { my ($self, $from, $alias) = @_; # subqueries and other oddness are naturally not supported @@ -453,7 +455,7 @@ sub _straight_join_to_node { # anyway, and deep cloning is just too fucking expensive # So replace the first hashref in the node arrayref manually my @new_from = ($from->[0]); - my $sw_idx = { map { values %$_ => 1 } @$switch_branch }; + my $sw_idx = { map { (values %$_), 1 } @$switch_branch }; #there's one k/v per join-path for my $j (@{$from}[1 .. $#$from]) { my $jalias = $j->[0]{-alias};