Retire DBIC/SqlMakerTest.pm now that SQLA::Test provides the same function
[dbsrgits/DBIx-Class.git] / t / resultset / bind_attr.t
index 62f4791..7f25d99 100644 (file)
@@ -3,9 +3,7 @@ use warnings;
 
 use Test::More;
 use lib qw(t/lib);
-use DBIC::SqlMakerTest;
-
-use_ok('DBICTest');
+use DBICTest ':DiffSQL';
 
 my $schema = DBICTest->init_schema;
 
@@ -16,9 +14,7 @@ my $where_bind = {
 
 my $rs;
 
-TODO: {
-    local $TODO = 'bind args order needs fixing (semifor)';
-
+{
     # First, the simple cases...
     $rs = $schema->resultset('Artist')->search(
             { artistid => 1 },
@@ -36,6 +32,13 @@ TODO: {
         ->search({}, $where_bind);
 
     is ( $rs->count, 1, 'where/bind last' );
+
+    # and the complex case
+    $rs = $schema->resultset('CustomSql')->search({}, { bind => [ 1999 ] })
+        ->search({ 'artistid' => 1 }, {
+            where => \'title like ?',
+            bind => [ 'Spoon%' ] });
+    is ( $rs->count, 1, '...cookbook + chained search with extra bind' );
 }
 
 {
@@ -66,12 +69,12 @@ TODO: {
       ->search({ 'artistid' => 1 });
   is ( $rs->count, 1, '...cookbook (bind first) + chained search' );
 
-  $rs = $schema->resultset('Complex')->search({}, { bind => [ 1999 ] })->search({}, { where => \"title LIKE ?", bind => [ 'Spoon%' ] });
+  $rs = $schema->resultset('Complex')->search({}, { bind => [ [{ sqlt_datatype => 'datetime'} => 1999 ] ] })->search({}, { where => \"title LIKE ?", bind => [ 'Spoon%' ] });
   is_same_sql_bind(
     $rs->as_query,
     "(SELECT me.artistid, me.name, me.rank, me.charfield FROM (SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year FROM artist a JOIN cd ON cd.artist = a.artistid WHERE cd.year = ?) me WHERE title LIKE ?)",
     [
-      [ {} => '1999' ],
+      [ { sqlt_datatype => 'datetime' } => '1999' ],
       [ {} => 'Spoon%' ]
     ],
     'got correct SQL'
@@ -107,13 +110,4 @@ TODO: {
   );
 }
 
-TODO: {
-    local $TODO = 'bind args order needs fixing (semifor)';
-    $rs = $schema->resultset('Complex')->search({}, { bind => [ 1999 ] })
-        ->search({ 'artistid' => 1 }, {
-            where => \'title like ?',
-            bind => [ 'Spoon%' ] });
-    is ( $rs->count, 1, '...cookbook + chained search with extra bind' );
-}
-
 done_testing;