And lose yet another dependency: List::Util (yes, I know it's core)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase / ASE.pm
index 3d66fa1..204ce12 100644 (file)
@@ -11,7 +11,6 @@ use base qw/
 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';
@@ -447,10 +446,10 @@ sub update {
     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 = \@_;
@@ -465,10 +464,10 @@ sub update {
   }
   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(@_);
   }
@@ -480,17 +479,14 @@ sub _insert_bulk {
 
   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 &&
@@ -553,7 +549,7 @@ sub _insert_bulk {
   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;