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
}
push @$inner_select, $sel;
+
+ push @{$inner_attrs->{as}}, $attrs->{as}[$i];
}
# construct the inner $from for the subquery
# 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 (
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/)
}),
],
selecting => [
- $self->_parse_order_by ($attrs->{order_by}, $sql_maker),
+ $self->_extract_order_columns ($attrs->{order_by}, $sql_maker),
$sql_maker->_recurse_fields ($select),
],
};
# 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';
# 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
return $cond;
}
-sub _parse_order_by {
+sub _extract_order_columns {
my ($self, $order_by, $sql_maker) = @_;
my $parser = sub {