Kill the plan
[dbsrgits/SQL-Abstract.git] / t / 02where.t
index 5592977..e6e1edd 100644 (file)
@@ -201,6 +201,24 @@ my @handle_tests = (
         stmt => " WHERE ( (bar > ? AND bar < ?) AND foo IN (?, ?) )",
         bind => [44, 55, 22, 33],
     },
+
+    {
+        where => {
+          -and => [
+            user => 'nwiger',
+            [
+              -and => [ workhrs => {'>', 20}, geo => 'ASIA' ],
+              -or => { workhrs => {'<', 50}, geo => 'EURO' },
+            ],
+          ],
+        },
+        stmt => "WHERE ( user = ? AND (
+               ( workhrs > ? AND geo = ? )
+            OR ( geo = ? OR workhrs < ? )
+          ) )",
+        bind => [qw/nwiger 20 ASIA EURO 50/],
+    },
+
    {
        where => { -and => [{}, { 'me.id' => '1'}] },
        stmt => " WHERE ( ( me.id = ? ) )",
@@ -328,8 +346,8 @@ my @handle_tests = (
        bind => [],
    },
    {
-       where => { timestamp => { '>=' => { -TO_DATE => '2009-12-21 00:00:00' } } },
-       stmt => " WHERE ( timestamp >= TO DATE ? )",
+       where => { timestamp => { '>=' => { -to_date => '2009-12-21 00:00:00' } } },
+       stmt => " WHERE ( timestamp >= TO_DATE ? )",
        bind => ['2009-12-21 00:00:00'],
    },
 
@@ -384,8 +402,6 @@ my @handle_tests = (
     },
 );
 
-plan tests => ( @handle_tests * 2 ) + 1;
-
 for my $case (@handle_tests) {
     local $Data::Dumper::Terse = 1;
     my $sql = SQL::Abstract->new;
@@ -401,3 +417,5 @@ dies_ok {
     my $sql = SQL::Abstract->new;
     $sql->where({ foo => { '>=' => [] }},);
 };
+
+done_testing;