Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / 93autocast.t
index 682755a..084f714 100644 (file)
@@ -1,10 +1,11 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+
 use strict;
 use warnings;
 
 use Test::More;
-use lib qw(t/lib);
+
 use DBICTest;
-use DBIC::SqlMakerTest;
 
 { # Fake storage driver for sqlite with autocast
     package DBICTest::SQLite::AutoCast;
@@ -20,7 +21,7 @@ use DBIC::SqlMakerTest;
       int => undef, # no conversion
     };
 
-    sub _map_data_type {
+    sub _native_data_type {
       return $type_map->{$_[1]};
     }
 }
@@ -33,50 +34,50 @@ my $rs = $schema->resultset ('CD')->search ({
   'tracks.last_updated_at' => { '!=', undef },
   'tracks.last_updated_on' => { '<', 2009 },
   'tracks.position' => 4,
-  'tracks.single_track' => \[ '= ?', [ single_track => [1, 2, 3 ] ] ],
+  'me.single_track' => \[ '= ?', [ single_track => 1 ] ],
 }, { join => 'tracks' });
 
-my $bind = [
-  [ cdid => 5 ],
-  [ 'tracks.last_updated_on' => 2009 ],
-  [ 'tracks.position' => 4 ],
-  [ 'single_track' => [ 1, 2, 3] ],
-];
+my @bind = (
+  [ { dbic_colname => "cdid", sqlt_datatype => "integer" }
+      => 5 ],
+  [ { dbic_colname => "single_track", sqlt_datatype => "integer" }
+      => 1 ],
+  [ { dbic_colname => "tracks.last_updated_on", sqlt_datatype => "datetime" }
+      => 2009 ],
+  [ { dbic_colname => "tracks.position", sqlt_datatype => "int" }
+      => 4 ],
+);
 
-is_same_sql_bind (
-  $rs->as_query,
-  '(
+$schema->is_executed_sql_bind( sub { $rs->all }, [[
+  '
     SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
       FROM cd me
       LEFT JOIN track tracks ON tracks.cd = me.cdid
     WHERE
           cdid > ?
+      AND me.single_track = ?
       AND tracks.last_updated_at IS NOT NULL
       AND tracks.last_updated_on < ?
       AND tracks.position = ?
-      AND tracks.single_track = ?
-  )',
-  $bind,
-  'expected sql with casting off',
-);
+  ',
+  @bind,
+]], 'expected sql with casting off' );
 
 $schema->storage->auto_cast (1);
 
-is_same_sql_bind (
-  $rs->as_query,
-  '(
+$schema->is_executed_sql_bind( sub { $rs->all }, [[
+  '
     SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
       FROM cd me
       LEFT JOIN track tracks ON tracks.cd = me.cdid
     WHERE
           cdid > CAST(? AS INT)
+      AND me.single_track = CAST(? AS INT)
       AND tracks.last_updated_at IS NOT NULL
-      AND tracks.last_updated_on < CAST (? AS yyy)
+      AND tracks.last_updated_on < CAST (? AS DateTime)
       AND tracks.position = ?
-      AND tracks.single_track = CAST(? AS INT)
-  )',
-  $bind,
-  'expected sql with casting on',
-);
+  ',
+  @bind,
+]], 'expected sql with casting on' );
 
 done_testing;