use base 'DBIx::Class::Storage';
use mro 'c3';
-use List::Util 'first';
use Scalar::Util 'blessed';
-use DBIx::Class::_Util qw(UNRESOLVABLE_CONDITION serialize);
+use DBIx::Class::_Util qw(UNRESOLVABLE_CONDITION serialize dump_value);
use SQL::Abstract qw(is_plain_value is_literal_value);
use DBIx::Class::Carp;
use namespace::clean;
my $inner_subq = do {
# must use it here regardless of user requests (vastly gentler on optimizer)
- local $self->{_use_join_optimizer} = 1;
+ local $self->{_use_join_optimizer} = 1
+ unless $self->{_use_join_optimizer};
# throw away multijoins since we def. do not care about those inside the subquery
# $inner_aliastypes *will* be redefined at this point
) {
push @outer_from, $j
}
- elsif (first { $_->{$alias} } @outer_nonselecting_chains ) {
+ elsif (grep { $_->{$alias} } @outer_nonselecting_chains ) {
push @outer_from, $j;
$may_need_outer_group_by ||= $outer_aliastypes->{multiplying}{$alias} ? 1 : 0;
}
( $_ = join ' ', map {
( ! defined $_ ) ? ()
- : ( length ref $_ ) ? (require Data::Dumper::Concise && $self->throw_exception(
- "Unexpected ref in scan-plan: " . Data::Dumper::Concise::Dumper($_)
- ))
+ : ( length ref $_ ) ? $self->throw_exception(
+ "Unexpected ref in scan-plan: " . dump_value $_
+ )
: ( $_ =~ /^\s*$/ ) ? ()
: $_
# for DESC, and group_by the root columns. The end result should be
# exactly what we expect
#
+
+ # both populated on the first loop over $o_idx
$sql_maker ||= $self->sql_maker;
$order_chunks ||= [
map { ref $_ eq 'ARRAY' ? $_ : [ $_ ] } $sql_maker->_order_by_chunks($attrs->{order_by})
# to an ordering alias into a MIN/MAX
$new_order_by[$o_idx] = \[
sprintf( '%s( %s )%s',
- ($is_desc ? 'MAX' : 'MIN'),
+ $self->_minmax_operator_for_datatype($chunk_ci->{data_type}, $is_desc),
$chunk,
($is_desc ? ' DESC' : ''),
),
);
}
+sub _minmax_operator_for_datatype {
+ #my ($self, $datatype, $want_max) = @_;
+
+ $_[2] ? 'MAX' : 'MIN';
+}
+
sub _resolve_ident_sources {
my ($self, $ident) = @_;
# extra sanity check
if (keys %$p > 1) {
- require Data::Dumper::Concise;
local $Data::Dumper::Deepcopy = 1;
$self->throw_exception(
"Internal error: unexpected collapse unroll:"
- . Data::Dumper::Concise::Dumper { in => { $lhs => $rhs }, out => $p }
+ . dump_value { in => { $lhs => $rhs }, out => $p }
);
}