[Bast-commits] r6132 - SQL-Abstract/1.x/branches/fix_nesting/t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Tue May 5 12:16:39 GMT 2009


Author: ribasushi
Date: 2009-05-05 12:16:38 +0000 (Tue, 05 May 2009)
New Revision: 6132

Modified:
   SQL-Abstract/1.x/branches/fix_nesting/t/01generate.t
   SQL-Abstract/1.x/branches/fix_nesting/t/07subqueries.t
Log:
Switch some tests to explicit parenthesis comparison

Modified: SQL-Abstract/1.x/branches/fix_nesting/t/01generate.t
===================================================================
--- SQL-Abstract/1.x/branches/fix_nesting/t/01generate.t	2009-05-05 12:13:34 UTC (rev 6131)
+++ SQL-Abstract/1.x/branches/fix_nesting/t/01generate.t	2009-05-05 12:16:38 UTC (rev 6132)
@@ -240,10 +240,11 @@
       {              
               func   => 'select',
               args   => ['Yo Momma', '*', { user => 'nwiger', 
-                                       -nest => [ workhrs => {'>', 20}, geo => 'ASIA' ] }],
-              stmt   => 'SELECT * FROM Yo Momma WHERE ( ( ( workhrs > ? ) OR ( geo = ? ) ) AND user = ? )',
-              stmt_q => 'SELECT * FROM `Yo Momma` WHERE ( ( ( `workhrs` > ? ) OR ( `geo` = ? ) ) AND `user` = ? )',
+                                       -paren => [ workhrs => {'>', 20}, geo => 'ASIA' ] }],
+              stmt   => 'SELECT * FROM Yo Momma WHERE ( ( (  workhrs > ? OR geo = ? ) AND user = ? ) )',
+              stmt_q => 'SELECT * FROM `Yo Momma` WHERE ( ( ( `workhrs` > ? OR `geo` = ? ) AND `user` = ? ) )',
               bind   => [qw(20 ASIA nwiger)],
+              keep_paren => 1,
       },             
       #28            
       {              
@@ -251,25 +252,27 @@
               args   => ['taco_punches', { one => 2, three => 4 },
                                          { bland => [ -and => {'!=', 'yes'}, {'!=', 'YES'} ],
                                            tasty => { '!=', [qw(yes YES)] },
-                                           -nest => [ face => [ -or => {'=', 'mr.happy'}, {'=', undef} ] ] },
+                                           -paren => [ face => [ -or => {'=', 'mr.happy'}, {'=', undef} ] ] },
                         ],
               stmt   => 'UPDATE taco_punches SET one = ?, three = ? WHERE ( ( ( ( ( face = ? ) OR ( face IS NULL ) ) ) )'
                       . ' AND ( ( bland != ? ) AND ( bland != ? ) ) AND ( ( tasty != ? ) OR ( tasty != ? ) ) )',
               stmt_q => 'UPDATE `taco_punches` SET `one` = ?, `three` = ? WHERE ( ( ( ( ( `face` = ? ) OR ( `face` IS NULL ) ) ) )'
                       . ' AND ( ( `bland` != ? ) AND ( `bland` != ? ) ) AND ( ( `tasty` != ? ) OR ( `tasty` != ? ) ) )',
               bind   => [qw(2 4 mr.happy yes YES yes YES)],
+              keep_paren => 1,
       },             
       #29            
       {              
               func   => 'select',
               args   => ['jeff', '*', { name => {'like', '%smith%', -not_in => ['Nate','Jim','Bob','Sally']},
-                                       -nest => [ -or => [ -and => [age => { -between => [20,30] }, age => {'!=', 25} ],
+                                       -paren => [ -or => [ -and => [age => { -between => [20,30] }, age => {'!=', 25} ],
                                                                    yob => {'<', 1976} ] ] } ],
-              stmt   => 'SELECT * FROM jeff WHERE ( ( ( ( ( ( ( age BETWEEN ? AND ? ) AND ( age != ? ) ) ) OR ( yob < ? ) ) ) )'
-                      . ' AND name NOT IN ( ?, ?, ?, ? ) AND name LIKE ? )',
-              stmt_q => 'SELECT * FROM `jeff` WHERE ( ( ( ( ( ( ( `age` BETWEEN ? AND ? ) AND ( `age` != ? ) ) ) OR ( `yob` < ? ) ) ) )'
-                      . ' AND `name` NOT IN ( ?, ?, ?, ? ) AND `name` LIKE ? )',
-              bind   => [qw(20 30 25 1976 Nate Jim Bob Sally %smith%)]
+              stmt   => 'SELECT * FROM jeff WHERE ( ( ( ( ( age BETWEEN ? AND ? ) AND age != ? ) OR yob < ? )'
+                      . ' AND ( name NOT IN ( ?, ?, ?, ? ) AND name LIKE ? ) ) )',
+              stmt_q => 'SELECT * FROM `jeff` WHERE ( ( ( ( ( `age` BETWEEN ? AND ? ) AND  `age` != ?) OR  `yob` < ? )'
+                      . ' AND ( `name` NOT IN ( ?, ?, ?, ? ) AND `name` LIKE ? ) ) )',
+              bind   => [qw(20 30 25 1976 Nate Jim Bob Sally %smith%)],
+              keep_paren => 1,
       },             
       #30            
       {              
@@ -279,13 +282,15 @@
 # acked by RIBASUSHI
 #              args   => ['fhole', {fpoles => 4}, [-maybe => {race => [-and => [qw(black white asian)]]},
               args   => ['fhole', {fpoles => 4}, [          {race => [-and => [qw(black white asian)]]},
-                                                            {-nest => {firsttime => [-or => {'=','yes'}, undef]}},
+                                                            {-paren => {firsttime => [-or => {'=','yes'}, undef]}},
                                                             [ -and => {firstname => {-not_like => 'candace'}}, {lastname => {-in => [qw(jugs canyon towers)]}} ] ] ],
-              stmt   => 'UPDATE fhole SET fpoles = ? WHERE ( ( ( ( ( ( ( race = ? ) OR ( race = ? ) OR ( race = ? ) ) ) ) ) )'
+              stmt   => 'UPDATE fhole SET fpoles = ? WHERE ( ( ( ( ( (  race = ?  OR ( race = ? ) OR ( race = ? ) ) ) ) ) )'
                       . ' OR ( ( ( ( firsttime = ? ) OR ( firsttime IS NULL ) ) ) ) OR ( ( ( firstname NOT LIKE ? ) ) AND ( lastname IN ( ?, ?, ? ) ) ) )',
               stmt_q => 'UPDATE `fhole` SET `fpoles` = ? WHERE ( ( ( ( ( ( ( `race` = ? ) OR ( `race` = ? ) OR ( `race` = ? ) ) ) ) ) )'
                       . ' OR ( ( ( ( `firsttime` = ? ) OR ( `firsttime` IS NULL ) ) ) ) OR ( ( ( `firstname` NOT LIKE ? ) ) AND ( `lastname` IN ( ?, ?, ? ) ) ) )',
-              bind   => [qw(4 black white asian yes candace jugs canyon towers)]
+              bind   => [qw(4 black white asian yes candace jugs canyon towers)],
+              keep_paren => 1,
+
       },
       #31
       {
@@ -556,6 +561,8 @@
   my $new = $_->{new} || {};
   $new->{debug} = $ENV{DEBUG} || 0;
 
+  local $SQL::Abstract::Test::parenthesis_significant = $_->{keep_paren};
+
   # test without quoting labels
   {
     my $sql = SQL::Abstract->new(%$new);

Modified: SQL-Abstract/1.x/branches/fix_nesting/t/07subqueries.t
===================================================================
--- SQL-Abstract/1.x/branches/fix_nesting/t/07subqueries.t	2009-05-05 12:13:34 UTC (rev 6131)
+++ SQL-Abstract/1.x/branches/fix_nesting/t/07subqueries.t	2009-05-05 12:16:38 UTC (rev 6132)
@@ -5,6 +5,7 @@
 use Test::More;
 
 use SQL::Abstract::Test import => ['is_same_sql_bind'];
+$SQL::Abstract::Test::parenthesis_significant = 1;
 
 use SQL::Abstract;
 
@@ -21,7 +22,7 @@
   };
 push @tests, {
   where => $where,
-  stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",
+  stmt => " WHERE ( ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? ) )",
   bind => [100, "foo%", 1234],
 };
 
@@ -35,7 +36,7 @@
   };
 push @tests, {
   where => $where,
-  stmt => " WHERE ( bar > ALL (SELECT c1 FROM t1 WHERE ( c2 < ? AND c3 LIKE ? )) AND foo = ? )",
+  stmt => " WHERE ( ( bar > ALL (SELECT c1 FROM t1 WHERE ( c2 < ? AND c3 LIKE ? )) AND foo = ? ) )",
   bind => [100, "foo%", 1234],
 };
 
@@ -44,17 +45,17 @@
      = $sql->select("t1", "*", {c1 => 1, c2 => \"> t0.c0"});
 $where = {
     foo                  => 1234,
-    -nest => \["EXISTS ($sub_stmt)" => @sub_bind],
+    -paren => \["EXISTS ($sub_stmt)" => @sub_bind],
   };
 push @tests, {
   where => $where,
-  stmt => " WHERE ( EXISTS (SELECT * FROM t1 WHERE ( c1 = ? AND c2 > t0.c0 )) AND foo = ? )",
+  stmt => " WHERE ( ( EXISTS (SELECT * FROM t1 WHERE ( c1 = ? AND c2 > t0.c0 )) AND foo = ? ) )",
   bind => [1, 1234],
 };
 
 #4
 $where = {
-    -nest => \["MATCH (col1, col2) AGAINST (?)" => "apples"],
+    -paren => \["MATCH (col1, col2) AGAINST (?)" => "apples"],
   };
 push @tests, {
   where => $where,
@@ -69,11 +70,11 @@
 $sub_stmt =~ s/^ where //i; # don't want "WHERE" in the subclause
 $where = {
     lname  => {-like => '%son%'},
-    -nest  => \["NOT ( $sub_stmt )" => @sub_bind],
+    -paren  => \["NOT ( $sub_stmt )" => @sub_bind],
   };
 push @tests, {
   where => $where,
-  stmt => " WHERE ( NOT ( ( ( ( age < ? ) OR ( age > ? ) ) ) ) AND lname LIKE ? )",
+  stmt => " WHERE ( ( NOT ( ( ( ( age < ? ) OR ( age > ? ) ) ) ) AND lname LIKE ? ) )",
   bind => [10, 20, '%son%'],
 };
 
@@ -86,7 +87,7 @@
   };
 push @tests, {
   where => $where,
-  stmt => " WHERE ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? )",
+  stmt => " WHERE ( ( bar IN (SELECT c1 FROM t1 WHERE c2 < ? AND c3 LIKE ?) AND foo = ? ) )",
   bind => [100, "foo%", 1234],
 };
 
@@ -98,8 +99,3 @@
   my($stmt, @bind) = $sql->where($_->{where}, $_->{order});
   is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
 }
-
-
-
-
-




More information about the Bast-commits mailing list