X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F93autocast.t;h=084f71467785413dcd3ff4989c7941ab4c916e91;hb=dc7d89911b7bb98c30208cf73af522a99998dcd6;hp=a0eb9d37f780a8b1823e567f505cf203e5029a88;hpb=0e773352a9c6c034dfb2526b8d68bf6ac1e2323b;p=dbsrgits%2FDBIx-Class.git diff --git a/t/93autocast.t b/t/93autocast.t index a0eb9d3..084f714 100644 --- a/t/93autocast.t +++ b/t/93autocast.t @@ -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; @@ -33,23 +34,22 @@ my $rs = $schema->resultset ('CD')->search ({ 'tracks.last_updated_at' => { '!=', undef }, 'tracks.last_updated_on' => { '<', 2009 }, 'tracks.position' => 4, - 'me.single_track' => \[ '= ?', [ single_track => [1, 2, 3 ] ] ], + 'me.single_track' => \[ '= ?', [ single_track => 1 ] ], }, { join => 'tracks' }); -my $bind = [ - [ { sqlt_datatype => 'integer', dbic_colname => 'cdid' } - => 5 ], - [ { sqlt_datatype => 'integer', dbic_colname => 'single_track' } - => [ 1, 2, 3] ], - [ { sqlt_datatype => 'datetime', dbic_colname => 'tracks.last_updated_on' } - => 2009 ], - [ { sqlt_datatype => 'int', dbic_colname => 'tracks.position' } - => 4 ], -]; +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 @@ -59,16 +59,14 @@ is_same_sql_bind ( AND tracks.last_updated_at IS NOT NULL AND tracks.last_updated_on < ? AND tracks.position = ? - )', - $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 @@ -78,9 +76,8 @@ is_same_sql_bind ( AND tracks.last_updated_at IS NOT NULL AND tracks.last_updated_on < CAST (? AS DateTime) AND tracks.position = ? - )', - $bind, - 'expected sql with casting on', -); + ', + @bind, +]], 'expected sql with casting on' ); done_testing;