From: Peter Rabbitson Date: Tue, 24 May 2016 08:40:12 +0000 (+0200) Subject: Remove last active reference to List::Util from lib/ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=58b92e31bbd259ddf1d32e342d3978cd43d6e1af;p=dbsrgits%2FDBIx-Class-Historic.git Remove last active reference to List::Util from lib/ This makes zero difference right now that List::Util/Scalar::Util/Sub::Util are one disgusting ball of mud, but hopefully it will make sense soon after @haarg's refactor finally ships --- diff --git a/lib/DBIx/Class/ResultSource/RowParser.pm b/lib/DBIx/Class/ResultSource/RowParser.pm index efd67b1..aff2b81 100644 --- a/lib/DBIx/Class/ResultSource/RowParser.pm +++ b/lib/DBIx/Class/ResultSource/RowParser.pm @@ -8,7 +8,6 @@ use base 'DBIx::Class'; use mro 'c3'; use Try::Tiny; -use List::Util 'max'; use DBIx::Class::ResultSource::RowParser::Util qw( assemble_simple_parser @@ -405,7 +404,14 @@ sub _resolve_collapse { # coderef later $collapse_map->{-identifying_columns} = []; $collapse_map->{-identifying_columns_variants} = [ sort { - (scalar @$a) <=> (scalar @$b) or max(@$a) <=> max(@$b) + (scalar @$a) <=> (scalar @$b) + or + ( + # Poor man's max() + ( sort { $b <=> $a } @$a )[0] + <=> + ( sort { $b <=> $a } @$b )[0] + ) } @collapse_sets ]; } } diff --git a/lib/DBIx/Class/Storage/DBI/Cursor.pm b/lib/DBIx/Class/Storage/DBI/Cursor.pm index ecd292b..6ea7004 100644 --- a/lib/DBIx/Class/Storage/DBI/Cursor.pm +++ b/lib/DBIx/Class/Storage/DBI/Cursor.pm @@ -182,10 +182,12 @@ sub all { (undef, $sth) = $self->storage->_select( @{$self->{args}} ); - return ( + ( DBIx::Class::_ENV_::SHUFFLE_UNORDERED_RESULTSETS and ! $self->{attrs}{order_by} + and + require List::Util ) ? List::Util::shuffle( @{$sth->fetchall_arrayref} ) : @{$sth->fetchall_arrayref} diff --git a/t/prefetch/o2m_o2m_order_by_with_limit.t b/t/prefetch/o2m_o2m_order_by_with_limit.t index fc447a2..5f0fffb 100644 --- a/t/prefetch/o2m_o2m_order_by_with_limit.t +++ b/t/prefetch/o2m_o2m_order_by_with_limit.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; - +use List::Util 'min'; use DBICTest ':DiffSQL'; use DBIx::Class::SQLMaker::LimitDialects; @@ -133,7 +133,7 @@ for ( is_deeply( $rs->all_hri, - [ @{$hri_contents}[$offset .. List::Util::min( $used_limit+$offset-1, $#$hri_contents)] ], + [ @{$hri_contents}[$offset .. min( $used_limit+$offset-1, $#$hri_contents)] ], "Correct slice of the resultset returned with limit '$limit', offset '$offset'", ); } diff --git a/xt/extra/lean_startup.t b/xt/extra/lean_startup.t index 4d73f4b..b5f5491 100644 --- a/xt/extra/lean_startup.t +++ b/xt/extra/lean_startup.t @@ -98,6 +98,7 @@ BEGIN { # these envvars *will* bring in more stuff than the baseline delete @ENV{qw( DBIC_TRACE + DBIC_SHUFFLE_UNORDERED_RESULTSETS DBICTEST_SQLT_DEPLOY DBICTEST_SQLITE_REVERSE_DEFAULT_ORDER DBICTEST_VIA_REPLICATED @@ -142,7 +143,6 @@ BEGIN { Sub::Quote Scalar::Util - List::Util Storable Class::Accessor::Grouped @@ -234,6 +234,7 @@ EOP my $art = $s->resultset('Artist')->create({ name => \[ '?' => 'foo'], rank => 42 }); $art->discard_changes; $art->update({ rank => 69, name => 'foo' }); + $s->resultset('Artist')->all; assert_no_missing_expected_requires(); }