[Bast-commits] r5970 - in SQL-Abstract/1.x/trunk: . lib/SQL t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu Apr 23 22:16:52 GMT 2009


Author: ribasushi
Date: 2009-04-23 23:16:52 +0100 (Thu, 23 Apr 2009)
New Revision: 5970

Modified:
   SQL-Abstract/1.x/trunk/
   SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
   SQL-Abstract/1.x/trunk/t/04modifiers.t
Log:
 r5860 at Thesaurus (orig r5859):  arcanez | 2009-04-07 18:37:24 +0200
  * branch to work on -and => [], -or => {}
 r5862 at Thesaurus (orig r5861):  arcanez | 2009-04-08 04:47:47 +0200
 fix for hashref $logic
 r5969 at Thesaurus (orig r5968):  arcanez | 2009-04-24 00:03:03 +0200
 readd the failing test back in
 r5970 at Thesaurus (orig r5969):  ribasushi | 2009-04-24 00:16:41 +0200
 Strip some parenthesis for easier reading



Property changes on: SQL-Abstract/1.x/trunk
___________________________________________________________________
Name: svk:merge
   - b9bda2dc-4395-4011-945f-8c81d782bde1:/branches/matthewt:18
b9bda2dc-4395-4011-945f-8c81d782bde1:/trunk:23
   + b9bda2dc-4395-4011-945f-8c81d782bde1:/branches/matthewt:18
b9bda2dc-4395-4011-945f-8c81d782bde1:/trunk:23
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/SQL-Abstract/1.x/branches/and_or:5969
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/SQL-Abstract:3093

Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm	2009-04-23 22:16:41 UTC (rev 5969)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm	2009-04-23 22:16:52 UTC (rev 5970)
@@ -528,9 +528,10 @@
 }
 
 sub _where_hashpair_HASHREF {
-  my ($self, $k, $v) = @_;
+  my ($self, $k, $v, $logic) = @_;
+  $logic ||= 'and';
 
-  my (@all_sql, @all_bind);
+  my ($all_sql, @all_bind);
 
   for my $op (sort keys %$v) {
     my $val = $v->{$op};
@@ -571,6 +572,10 @@
           @bind = @sub_bind;
         },
 
+        HASHREF => sub {
+          ($sql, @bind) = $self->_where_hashpair_HASHREF($k, $val, $op);
+        },
+
         UNDEF => sub {          # CASE: col => {op => undef} : sql "IS (NOT)? NULL"
           my $is = ($op =~ $self->{equality_op})   ? 'is'     :
                    ($op =~ $self->{inequality_op}) ? 'is not' :
@@ -587,11 +592,10 @@
       });
     }
 
-    push @all_sql, $sql;
+    ($all_sql) = (defined $all_sql and $all_sql) ? $self->_join_sql_clauses($logic, [$all_sql, $sql], []) : $sql;
     push @all_bind, @bind;
   }
-
-  return $self->_join_sql_clauses('and', \@all_sql, \@all_bind);
+  return ($all_sql, @all_bind);
 }
 
 

Modified: SQL-Abstract/1.x/trunk/t/04modifiers.t
===================================================================
--- SQL-Abstract/1.x/trunk/t/04modifiers.t	2009-04-23 22:16:41 UTC (rev 5969)
+++ SQL-Abstract/1.x/trunk/t/04modifiers.t	2009-04-23 22:16:52 UTC (rev 5970)
@@ -145,7 +145,6 @@
   },
   # test column multi-cond in arrayref (even more useful)
   {
-#    todo => 'Clarify semantics in 1.52',
     where => { x => { '!=' => [ -and => (1 .. 3) ] } },
     stmt => 'WHERE x != ? AND x != ? AND x != ?',
     bind => [1..3],
@@ -153,12 +152,11 @@
 
   # the -or should affect only the inner hashref, as we are not in an outer arrayref
   {
-#    todo => 'Clarify semantics in 1.52',
     where => { x => {
       -or => { '!=', 1, '>=', 2 }, -like => 'x%'
     }},
-    stmt => 'WHERE (x != ? OR x >= ?) AND x LIKE ?',
-    bind => [qw/1 2 x%/],
+    stmt => 'WHERE x LIKE ? AND ( x != ? OR x >= ? )',
+    bind => [qw/x% 1 2/],
   },
 
   # the -and should affect the OUTER arrayref, while the internal structures remain intact




More information about the Bast-commits mailing list