Adjust for SQLA's API change 966200cc8
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBIHacks.pm
index f13be43..17fdbfb 100644 (file)
@@ -1124,8 +1124,8 @@ sub _collapse_cond {
   for my $col ( grep { $_ !~ /^\-/ } keys %$fin ) {
     next unless ref $fin->{$col} eq 'ARRAY' and ($fin->{$col}[0]||'') =~ /^\-and$/i;
     my $val_bag = { map {
-      (! defined $_ )                   ? ( UNDEF => undef )
-    : ( ! ref $_ or is_plain_value $_ ) ? ( "VAL_$_" => $_ )
+      (! defined $_ )                          ? ( UNDEF => undef )
+    : ( ! length ref $_ or is_plain_value $_ ) ? ( "VAL_$_" => $_ )
     : ( ( 'SER_' . serialize $_ ) => $_ )
     } @{$fin->{$col}}[1 .. $#{$fin->{$col}}] };
 
@@ -1223,6 +1223,18 @@ sub _collapse_cond_unroll_pairs {
           push @conds, { $lhs => $rhs };
         }
       }
+      # unroll func + { -value => ... }
+      elsif (
+        ref $rhs eq 'HASH'
+          and
+        ( my ($subop) = keys %$rhs ) == 1
+          and
+        length ref ((values %$rhs)[0])
+          and
+        my $vref = is_plain_value( (values %$rhs)[0] )
+      ) {
+        push @conds, { $lhs => { $subop => $$vref } }
+      }
       else {
         push @conds, { $lhs => $rhs };
       }