No tabs, no trailers
[dbsrgits/SQL-Abstract.git] / t / 00new.t
index 989a0b2..bbba692 100644 (file)
--- a/t/00new.t
+++ b/t/00new.t
@@ -4,18 +4,10 @@ use strict;
 use warnings;
 use Test::More;
 
-use FindBin;
-use lib "$FindBin::Bin";
-use TestSqlAbstract;
-
-
-plan tests => 15;
-
-use_ok('SQL::Abstract');
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
 
 #LDNOTE: renamed all "bind" into "where" because that's what they are
 
-
 my @handle_tests = (
       #1
       {
@@ -23,8 +15,10 @@ my @handle_tests = (
 #              stmt => 'SELECT * FROM test WHERE ( a = ? OR b = ? )'
 # LDNOTE: modified the line above (changing the test suite!!!) because
 # the test was not consistent with the doc: hashrefs should not be
-# influenced by the current logic, they always mean 'AND'. So 
+# influenced by the current logic, they always mean 'AND'. So
 # { a => 4, b => 0} should ALWAYS mean ( a = ? AND b = ? ).
+#
+# acked by RIBASUSHI
               stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
       },
       #2
@@ -47,6 +41,7 @@ my @handle_tests = (
               args => {cmp => "=", logic => 'or'},
 # LDNOTE idem
 #              stmt => 'SELECT * FROM test WHERE ( a = ? OR b = ? )'
+# acked by RIBASUSHI
               stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
       },
       #6
@@ -59,6 +54,7 @@ my @handle_tests = (
               args => {logic => "or", cmp => "like"},
 # LDNOTE idem
 #              stmt => 'SELECT * FROM test WHERE ( a LIKE ? OR b LIKE ? )'
+# acked by RIBASUSHI
               stmt => 'SELECT * FROM test WHERE ( a LIKE ? AND b LIKE ? )'
       },
       #8
@@ -95,24 +91,19 @@ my @handle_tests = (
       #14
       {
               args => {convert => "upper"},
-# LDNOTE : modified the test below, because modified the semantics
-# of "e => { '!=', [qw(f g)] }" : generating "e != 'f' OR e != 'g'"
-# is nonsense (will always be true whatever the value of e). Since
-# this is a 'negative' operator, we must apply the Morgan laws and
-# interpret it as "e != 'f' AND e != 'g'" (and actually the user
-# should rather write "e => {-not_in => [qw/f g/]}".
-
-#              stmt => 'SELECT * FROM test WHERE ( ( UPPER(hostname) IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) AND ( ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) ) ) OR ( UPPER(tack) BETWEEN UPPER(?) AND UPPER(?) ) OR ( ( ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) ) AND ( ( UPPER(e) != UPPER(?) ) OR ( UPPER(e) != UPPER(?) ) ) AND UPPER(q) NOT IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) ) )',
-              stmt => 'SELECT * FROM test WHERE ( ( UPPER(hostname) IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) AND ( ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) ) ) OR ( UPPER(tack) BETWEEN UPPER(?) AND UPPER(?) ) OR ( ( ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) ) AND ( ( UPPER(e) != UPPER(?) ) AND ( UPPER(e) != UPPER(?) ) ) AND UPPER(q) NOT IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) ) )',
-              where => [ { ticket => [11, 12, 13], 
+              stmt => 'SELECT * FROM test WHERE ( ( UPPER(hostname) IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) AND ( ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) ) ) OR ( UPPER(tack) BETWEEN UPPER(?) AND UPPER(?) ) OR ( ( ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) ) AND ( ( UPPER(e) != UPPER(?) ) OR ( UPPER(e) != UPPER(?) ) ) AND UPPER(q) NOT IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) ) )',
+              where => [ { ticket => [11, 12, 13],
                            hostname => { in => ['ntf', 'avd', 'bvd', '123'] } },
                         { tack => { between => [qw/tick tock/] } },
-                        { a => [qw/b c d/], 
-                          e => { '!=', [qw(f g)] }, 
+                        { a => [qw/b c d/],
+                          e => { '!=', [qw(f g)] },
                           q => { 'not in', [14..20] } } ],
       },
 );
 
+
+use_ok('SQL::Abstract');
+
 for (@handle_tests) {
   local $" = ', ';
   #print "creating a handle with args ($_->{args}): ";
@@ -126,4 +117,4 @@ for (@handle_tests) {
   is_same_sql_bind($stmt, [@bind ? 1 : 0], $_->{stmt}, [1]);
 }
 
-
+done_testing;