[Bast-commits] r5976 - in SQL-Abstract/1.x/branches/and_or: lib/SQL t

arcanez at dev.catalyst.perl.org arcanez at dev.catalyst.perl.org
Fri Apr 24 08:03:46 GMT 2009


Author: arcanez
Date: 2009-04-24 09:03:45 +0100 (Fri, 24 Apr 2009)
New Revision: 5976

Modified:
   SQL-Abstract/1.x/branches/and_or/lib/SQL/Abstract.pm
   SQL-Abstract/1.x/branches/and_or/t/04modifiers.t
Log:
fix for x => { '!=' => [ -and => (1 .. 3) ] }
added parens for test


Modified: SQL-Abstract/1.x/branches/and_or/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/branches/and_or/lib/SQL/Abstract.pm	2009-04-23 23:47:04 UTC (rev 5975)
+++ SQL-Abstract/1.x/branches/and_or/lib/SQL/Abstract.pm	2009-04-24 08:03:45 UTC (rev 5976)
@@ -360,11 +360,13 @@
 
 
 sub _where_ARRAYREF {
-  my ($self, $where, $logic) = @_;
+  my ($self, $where, $_logic) = @_;
 
-  $logic = uc($logic || $self->{logic});
+  my $logic = uc($_logic || $self->{logic});
   $logic eq 'AND' or $logic eq 'OR' or puke "unknown logic: $logic";
 
+  my $orig_logic = $self->{logic};
+
   my @clauses = @$where;
 
   my (@sql_clauses, @all_bind);
@@ -399,6 +401,7 @@
       push @all_bind, @bind;
     }
   }
+  $logic = $self->{logic} if $orig_logic ne $self->{logic} and !$_logic;
 
   return $self->_join_sql_clauses($logic, \@sql_clauses, \@all_bind);
 }
@@ -584,6 +587,11 @@
         },
         
         FALLBACK => sub {       # CASE: col => {op => $scalar}
+          if ($val =~ /^ - ( AND|OR ) $/ix) {
+            $self->{logic} = uc $1;
+            delete $v->{$op};
+            return '', ();
+          }
           $sql  = join ' ', $self->_convert($self->_quote($k)),
                             $self->_sqlcase($op),
                             $self->_convert('?');

Modified: SQL-Abstract/1.x/branches/and_or/t/04modifiers.t
===================================================================
--- SQL-Abstract/1.x/branches/and_or/t/04modifiers.t	2009-04-23 23:47:04 UTC (rev 5975)
+++ SQL-Abstract/1.x/branches/and_or/t/04modifiers.t	2009-04-24 08:03:45 UTC (rev 5976)
@@ -146,7 +146,7 @@
   # test column multi-cond in arrayref (even more useful)
   {
     where => { x => { '!=' => [ -and => (1 .. 3) ] } },
-    stmt => 'WHERE x != ? AND x != ? AND x != ?',
+    stmt => 'WHERE ( ( x != ? AND x != ? AND x != ? ) )',
     bind => [1..3],
   },
 




More information about the Bast-commits mailing list