###
'DBI' => '1.57',
- # on older versions first() leaks
- # for the time being make it a hard dep - when we get
- # rid of Sub::Name will revisit this (possibility is
- # to use Devel::HideXS to force the pure-perl version
- # or something like that)
- 'List::Util' => '1.16',
-
# XS (or XS-dependent) libs
'Sub::Name' => '0.04',
use warnings;
use base qw( DBIx::Class );
-use List::Util 'first';
-use namespace::clean;
-
=head1 NAME
DBIx::Class::Ordered - Modify the position of objects in an ordered list.
if (! keys %$changed_ordering_cols) {
return $self->next::method( undef, @_ );
}
- elsif (defined first { exists $changed_ordering_cols->{$_} } @group_columns ) {
+ elsif (grep { exists $changed_ordering_cols->{$_} } @group_columns ) {
$self->move_to_group(
# since the columns are already re-set the _grouping_clause is correct
# move_to_group() knows how to get the original storage values
# add the current position/group to the things we track old values for
sub _track_storage_value {
my ($self, $col) = @_;
- return $self->next::method($col) || defined first { $_ eq $col } ($self->position_column, $self->_grouping_columns);
+ return (
+ $self->next::method($col)
+ ||
+ grep { $_ eq $col } ($self->position_column, $self->_grouping_columns)
+ );
}
=head1 METHODS FOR EXTENDING ORDERED
local $rsrc->schema->{_ORDERED_INTERNAL_UPDATE} = 1;
my @pcols = $rsrc->primary_columns;
if (
- first { $_ eq $position_column } ( map { @$_ } (values %{{ $rsrc->unique_constraints }} ) )
+ grep { $_ eq $position_column } ( map { @$_ } (values %{{ $rsrc->unique_constraints }} ) )
) {
my $clean_rs = $rsrc->resultset;
);
use Try::Tiny;
-# not importing first() as it will clash with our own method
-use List::Util ();
-
BEGIN {
# De-duplication in _merge_attr() is disabled, but left in for reference
# (the merger is used for other things that ought not to be de-duped)
# see if we can keep the cache (no $rs changes)
my $cache;
my %safe = (alias => 1, cache => 1);
- if ( ! List::Util::first { !$safe{$_} } keys %$call_attrs and (
+ if ( ! grep { !$safe{$_} } keys %$call_attrs and (
! defined $call_cond
or
ref $call_cond eq 'HASH' && ! keys %$call_cond
my @selector_attrs = qw/select as columns cols +select +as +columns include_columns/;
# reset the current selector list if new selectors are supplied
- if (List::Util::first { exists $call_attrs->{$_} } qw/columns cols select as/) {
- delete @{$old_attrs}{(@selector_attrs, '_dark_selector')};
- }
+ delete @{$old_attrs}{(@selector_attrs, '_dark_selector')}
+ if grep { exists $call_attrs->{$_} } qw(columns cols select as);
# Normalize the new selector list (operates on the passed-in attr structure)
# Need to do it on every chain instead of only once on _resolved_attrs, in
$storage->_prune_unused_joins ($attrs);
# any non-pruneable non-local restricting joins imply subq
- $needs_subq = defined List::Util::first { $_ ne $attrs->{alias} } keys %{ $join_classifications->{restricting} || {} };
+ $needs_subq = grep { $_ ne $attrs->{alias} } keys %{ $join_classifications->{restricting} || {} };
}
# check if the head is composite (by now all joins are thrown out unless $needs_subq)
# default selection list
$attrs->{columns} = [ $source->columns ]
- unless List::Util::first { exists $attrs->{$_} } qw/columns cols select as/;
+ unless grep { exists $attrs->{$_} } qw/columns cols select as/;
# merge selectors together
for (qw/columns select as/) {
if (
! $attrs->{_main_source_premultiplied}
and
- ! List::Util::first { ! $_->[0]{-is_single} } @fromlist
+ ! grep { ! $_->[0]{-is_single} } @fromlist
) {
$attrs->{collapse} = 0;
}
},
ARRAY => sub {
return $_[1] if !defined $_[0];
- return $_[1] if __HM_DEDUP and List::Util::first { $_ eq $_[0] } @{$_[1]};
+ return $_[1] if __HM_DEDUP and grep { $_ eq $_[0] } @{$_[1]};
return [$_[0], @{$_[1]}]
},
HASH => sub {
ARRAY => {
SCALAR => sub {
return $_[0] if !defined $_[1];
- return $_[0] if __HM_DEDUP and List::Util::first { $_ eq $_[1] } @{$_[0]};
+ return $_[0] if __HM_DEDUP and grep { $_ eq $_[1] } @{$_[0]};
return [@{$_[0]}, $_[1]]
},
ARRAY => sub {
HASH => sub {
return [ $_[1] ] if ! @{$_[0]};
return $_[0] if !keys %{$_[1]};
- return $_[0] if __HM_DEDUP and List::Util::first { $_ eq $_[1] } @{$_[0]};
+ return $_[0] if __HM_DEDUP and grep { $_ eq $_[1] } @{$_[0]};
return [ @{$_[0]}, $_[1] ];
},
},
return [] if !keys %{$_[0]} and !@{$_[1]};
return [ $_[0] ] if !@{$_[1]};
return $_[1] if !keys %{$_[0]};
- return $_[1] if __HM_DEDUP and List::Util::first { $_ eq $_[0] } @{$_[1]};
+ return $_[1] if __HM_DEDUP and grep { $_ eq $_[0] } @{$_[1]};
return [ $_[0], @{$_[1]} ];
},
HASH => sub {
use DBIx::Class::_Util 'fail_on_internal_wantarray';
use namespace::clean;
-# not importing first() as it will clash with our own method
-use List::Util ();
-
=head1 NAME
DBIx::Class::ResultSetColumn - helpful methods for messing
# (to create a new column definition on-the-fly).
my $as_list = $orig_attrs->{as} || [];
my $select_list = $orig_attrs->{select} || [];
- my $as_index = List::Util::first { ($as_list->[$_] || "") eq $column } 0..$#$as_list;
+ my ($as_index) = grep { ($as_list->[$_] || "") eq $column } 0..$#$as_list;
my $select = defined $as_index ? $select_list->[$as_index] : $column;
my $colmap;
use base 'DBIx::Class';
use Try::Tiny;
-use List::Util qw(first max);
+use List::Util 'max';
use DBIx::Class::ResultSource::RowParser::Util qw(
assemble_simple_parser
# if there is at least one *inner* reverse relationship which is HASH-based (equality only)
# we can safely assume that the child can not exist without us
- rev_rel_is_optional => ( first
+ rev_rel_is_optional => ( grep
{ ref $_->{cond} eq 'HASH' and ($_->{attrs}{join_type}||'') !~ /^left/i }
values %{ $self->reverse_relationship_info($rel) },
) ? 0 : 1,
use base qw/DBIx::Class/;
use Scalar::Util 'blessed';
-use List::Util 'first';
use DBIx::Class::_Util 'dbic_internal_try';
use DBIx::Class::Carp;
use SQL::Abstract qw( is_literal_value is_plain_value );
# value tracked between column changes and commitment to storage
sub _track_storage_value {
my ($self, $col) = @_;
- return defined first { $col eq $_ } ($self->result_source->primary_columns);
+ return scalar grep
+ { $col eq $_ }
+ $self->result_source->primary_columns
+ ;
}
=head2 set_columns
use warnings;
use strict;
-use List::Util 'first';
-use namespace::clean;
-
# constants are used not only here, but also in comparison tests
sub __rows_bindtype () {
+{ sqlt_datatype => 'integer' }
use DBIx::Class::Carp;
use Scalar::Util qw/refaddr weaken reftype blessed/;
-use List::Util qw/first/;
use Context::Preserve 'preserve_context';
use Try::Tiny;
use SQL::Abstract qw(is_plain_value is_literal_value);
and
$op eq 'select'
and
- first {
+ grep {
length ref $_->[1]
and
blessed($_->[1])
use mro 'c3';
use DBI ();
-use List::Util 'first';
-use namespace::clean;
__PACKAGE__->sql_limit_dialect ('Top');
__PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::ACCESS');
my $columns_info = $source->columns_info;
if (keys %$to_insert == 0) {
- my $autoinc_col = first {
+ my ($autoinc_col) = grep {
$columns_info->{$_}{is_auto_increment}
} keys %$columns_info;
use base 'DBIx::Class::Cursor';
use Scalar::Util qw(refaddr weaken);
-use List::Util 'shuffle';
use DBIx::Class::_Util qw( detected_reinvoked_destructor dbic_internal_try );
use namespace::clean;
and
! $self->{attrs}{order_by}
)
- ? shuffle @{$sth->fetchall_arrayref}
+ ? List::Util::shuffle( @{$sth->fetchall_arrayref} )
: @{$sth->fetchall_arrayref}
;
}
use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';
-use Try::Tiny;
-use namespace::clean;
__PACKAGE__->datetime_parser_type('DateTime::Format::DB2');
__PACKAGE__->sql_quote_char ('"');
use warnings;
use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';
-use List::Util 'first';
-use namespace::clean;
=head1 NAME
$generator = uc $generator unless $quoted;
return $generator
- if first {
+ if grep {
$self->sql_maker->quote_char ? ($_ eq $col) : (uc($_) eq uc($col))
} @trig_cols;
}
use base 'DBIx::Class::Storage::DBI';
use mro 'c3';
-use namespace::clean;
-
=head1 NAME
DBIx::Class::Storage::DBI::IdentityInsert - Storage Component for Sybase ASE and
use Try::Tiny;
use DBIx::Class::_Util qw( dbic_internal_try sigwarn_silencer );
-use List::Util 'first';
use namespace::clean;
__PACKAGE__->mk_group_accessors(simple => qw/
use mro 'c3';
use DBIx::Class::SQLMaker::LimitDialects;
-use List::Util qw/first/;
-
-use namespace::clean;
=head1 NAME
use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';
-use Try::Tiny;
-use namespace::clean;
sub _rebless {
my ($self) = @_;
use DBIx::Class::Carp;
use Scope::Guard ();
use Context::Preserve 'preserve_context';
-use List::Util 'first';
use DBIx::Class::_Util qw( modver_gt_or_eq_and_lt dbic_internal_try );
use namespace::clean;
my ($self, $sql, $bind) = @_[0,2,3];
# Turn off sth caching for multi-part LOBs. See _prep_for_execute below
- local $self->{disable_sth_caching} = 1 if first {
+ local $self->{disable_sth_caching} = 1 if grep {
($_->[0]{_ora_lob_autosplit_part}||0)
>
(__cache_queries_with_max_lob_parts - 1)
use Moose;
use DBIx::Class::Storage::DBI::Replicated::Replicant;
-use List::Util 'sum';
use Scalar::Util 'reftype';
use DBI ();
use MooseX::Types::Moose qw/Num Int ClassName HashRef/;
=cut
sub connected_replicants {
- my $self = shift @_;
- return sum( map {
- $_->connected ? 1:0
- } $self->all_replicants );
+ return scalar grep
+ { $_->connected }
+ shift->all_replicants
+ ;
}
=head2 active_replicants
use warnings;
use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/;
use mro 'c3';
-use List::Util 'first';
use DBIx::Class::_Util 'dbic_internal_try';
use Try::Tiny;
use namespace::clean;
my $values = $self->next::method(@_);
- my $identity_col =
- first { $colinfo->{$_}{is_auto_increment} } keys %$colinfo;
+ my ($identity_col) =
+ grep { $colinfo->{$_}{is_auto_increment} } keys %$colinfo;
# user might have an identity PK without is_auto_increment
#
use mro 'c3';
use DBIx::Class::Carp;
use Scalar::Util qw/blessed weaken/;
-use List::Util 'first';
use Sub::Name();
use Try::Tiny;
use Context::Preserve 'preserve_context';
if (keys %$fields) {
# Now set the identity update flags for the actual update
- local $self->{_autoinc_supplied_for_op} = (first
+ local $self->{_autoinc_supplied_for_op} = grep
{ $_->{is_auto_increment} }
values %{ $source->columns_info([ keys %$fields ]) }
- ) ? 1 : 0;
+ ;
my $next = $self->next::can;
my $args = \@_;
}
else {
# Set the identity update flags for the actual update
- local $self->{_autoinc_supplied_for_op} = (first
+ local $self->{_autoinc_supplied_for_op} = grep
{ $_->{is_auto_increment} }
values %{ $source->columns_info([ keys %$fields ]) }
- ) ? 1 : 0;
+ ;
return $self->next::method(@_);
}
my $columns_info = $source->columns_info;
- my $identity_col =
- first { $columns_info->{$_}{is_auto_increment} }
+ my ($identity_col) =
+ grep { $columns_info->{$_}{is_auto_increment} }
keys %$columns_info;
# FIXME - this is duplication from DBI.pm. When refactored towards
# the LobWriter this can be folded back where it belongs.
- local $self->{_autoinc_supplied_for_op} =
- (first { $_ eq $identity_col } @$cols)
- ? 1
- : 0
- ;
+ local $self->{_autoinc_supplied_for_op}
+ = grep { $_ eq $identity_col } @$cols;
my $use_bulk_api =
$self->_bulk_storage &&
my @source_columns = $source->columns;
# bcp identity index is 1-based
- my $identity_idx = first { $source_columns[$_] eq $identity_col } (0..$#source_columns);
+ my ($identity_idx) = grep { $source_columns[$_] eq $identity_col } (0..$#source_columns);
$identity_idx = defined $identity_idx ? $identity_idx + 1 : 0;
my @new_data;
DBIx::Class::Storage::DBI::Sybase::ASE
/;
use mro 'c3';
-use List::Util 'first';
use Scalar::Util 'looks_like_number';
use namespace::clean;
return $self->next::method(@_) if not defined $value or not defined $type;
- if (my $key = first { $type =~ /$_/i } keys %noquote) {
+ if (my ($key) = grep { $type =~ /$_/i } keys %noquote) {
return 1 if $noquote{$key}->($value);
}
elsif ($self->is_datatype_numeric($type) && $number->($value)) {
use base qw/DBIx::Class::Storage::DBI/;
-use namespace::clean;
-
__PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::MySQL');
__PACKAGE__->sql_limit_dialect ('LimitXY');
__PACKAGE__->sql_quote_char ('`');
use base 'DBIx::Class::Storage';
use mro 'c3';
-use List::Util 'first';
use Scalar::Util 'blessed';
use DBIx::Class::_Util qw(UNRESOLVABLE_CONDITION serialize dump_value);
use SQL::Abstract qw(is_plain_value is_literal_value);
) {
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;
}
use Carp 'croak';
use Storable 'nfreeze';
use Scalar::Util qw(weaken blessed reftype refaddr);
-use List::Util qw(first);
use Sub::Quote qw(qsub quote_sub);
# Already correctly prototyped: perlbrew exec perl -MStorable -e 'warn prototype \&Storable::dclone'
[[ "$CLEANTEST" != "true" ]] && echo_err "Breaking the compiler without CLEANTEST makes no sense" && exit 1
# FIXME - working around RT#74707, https://metacpan.org/source/DOY/Package-Stash-0.37/Makefile.PL#L112-122
- # List::Util can be excised after that as well (need to make my own max() routine for older perls)
#
# DEVREL_DEPS means our installer is cpanm, which will respect failures
# and the like, so stuff soft-failing (failed deps that are not in fact
# FIXME - the PathTools 3.47 is to work around https://rt.cpan.org/Ticket/Display.html?id=107392
#
installdeps Sub::Name Clone Package::Stash::XS \
- $( perl -MList::Util\ 1.16 -e1 &>/dev/null || echo "List::Util" ) \
$( [[ "$DEVREL_DEPS" == "true" ]] && ( perl -MFile::Spec\ 3.13 -e1 &>/dev/null || echo "S/SM/SMUELLER/PathTools-3.47.tar.gz" ) ) \
$( perl -MDBI -e1 &>/dev/null || echo "DBI" ) \
$( perl -MDBD::SQLite -e1 &>/dev/null || echo "DBD::SQLite" )
use strict;
use Test::More;
-use List::Util 'first';
use Module::Runtime 'require_module';
use lib 'maint/.Generated_Pod/lib';
use DBICTest;
SKIP: {
my ($match) =
- first { $module =~ $_ }
+ grep { $module =~ $_ }
(sort { length $b <=> length $a || $b cmp $a } (keys %$ex_lookup) )
;