Add support for DELETE ... RETURNING ...
[scpubgit/Q-Branch.git] / t / 01generate.t
index 948317f..e6d1c6c 100644 (file)
@@ -128,10 +128,10 @@ my @tests = (
       },
       {
               func   => 'insert',
-              args   => ['test', [qw/1 2 3 4 5/]],
-              stmt   => 'INSERT INTO test VALUES (?, ?, ?, ?, ?)',
-              stmt_q => 'INSERT INTO `test` VALUES (?, ?, ?, ?, ?)',
-              bind   => [qw/1 2 3 4 5/],
+              args   => ['test', [1..30]],
+              stmt   => 'INSERT INTO test VALUES ('.join(', ', ('?')x30).')',
+              stmt_q => 'INSERT INTO `test` VALUES ('.join(', ', ('?')x30).')',
+              bind   => [1..30],
       },
       {
               func   => 'insert',
@@ -595,6 +595,27 @@ my @tests = (
               stmt_q => 'UPDATE `mytable` SET `foo` = ? WHERE `baz` = ? RETURNING `id`, `created_at`',
               bind => [42, 32],
       },
+      {
+              func   => 'delete',
+              args   => ['test', {requestor => undef}, {returning => 'id'}],
+              stmt   => 'DELETE FROM test WHERE ( requestor IS NULL ) RETURNING id',
+              stmt_q => 'DELETE FROM `test` WHERE ( `requestor` IS NULL ) RETURNING `id`',
+              bind   => []
+      },
+      {
+              func   => 'delete',
+              args   => ['test', {requestor => undef}, {returning => \'*'}],
+              stmt   => 'DELETE FROM test WHERE ( requestor IS NULL ) RETURNING *',
+              stmt_q => 'DELETE FROM `test` WHERE ( `requestor` IS NULL ) RETURNING *',
+              bind   => []
+      },
+      {
+              func   => 'delete',
+              args   => ['test', {requestor => undef}, {returning => ['id', 'created_at']}],
+              stmt   => 'DELETE FROM test WHERE ( requestor IS NULL ) RETURNING id, created_at',
+              stmt_q => 'DELETE FROM `test` WHERE ( `requestor` IS NULL ) RETURNING `id`, `created_at`',
+              bind   => []
+      },
 );
 
 # check is( not) => undef