Passing a hashref as bind value in insert() does not blow up, but passes the hashref...
[scpubgit/Q-Branch.git] / t / 01generate.t
index 000d6f7..319f1a9 100644 (file)
@@ -5,7 +5,6 @@ use warnings;
 use Test::More;
 
 use SQL::Abstract::Test import => ['is_same_sql_bind'];
-plan tests => 72;
 
 use SQL::Abstract;
 
@@ -345,9 +344,34 @@ my @tests = (
               stmt_q => 'UPDATE `test` SET `a` = ?, `b` = ?',
               bind   => [[a => 1], [b => [1, 1, 2, 3, 5, 8]]],
       },
+      #37
+      {
+              func   => 'select',
+              args   => ['test', '*', { a => {'>', \'1 + 1'}, b => 8 }],
+              stmt   => 'SELECT * FROM test WHERE ( a > 1 + 1 AND b = ? )',
+              stmt_q => 'SELECT * FROM `test` WHERE ( `a` > 1 + 1 AND `b` = ? )',
+              bind   => [8],
+      },             
+      #38
+      {
+              func   => 'select',
+              args   => ['test', '*', { a => {'<' => \["to_date(?, 'MM/DD/YY')", '02/02/02']}, b => 8 }],
+              stmt   => 'SELECT * FROM test WHERE ( a < to_date(?, \'MM/DD/YY\') AND b = ? )',
+              stmt_q => 'SELECT * FROM `test` WHERE ( `a` < to_date(?, \'MM/DD/YY\') AND `b` = ? )',
+              bind   => ['02/02/02', 8],
+      },             
+      #39            
+      { #TODO in SQLA >= 2.0 it will die instead (we kept this just because old SQLA passed it through)
+              func   => 'insert',
+              args   => ['test', {a => 1, b => 2, c => 3, d => 4, e => { answer => 42 }}],
+              stmt   => 'INSERT INTO test (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)',
+              stmt_q => 'INSERT INTO `test` (`a`, `b`, `c`, `d`, `e`) VALUES (?, ?, ?, ?, ?)',
+              bind   => [qw/1 2 3 4/, { answer => 42}],
+      },             
 );
 
-use Data::Dumper;
+
+plan tests => scalar(@tests) * 2;
 
 for (@tests) {
   local $"=', ';