X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fresultset%2Fbind_attr.t;h=a636cfc1533a62018e5bb8c8e0a4ba63fb672dd9;hb=adcc1df0049e0093cb94c867bd2be8c9fe242a61;hp=62f4791f2e3173785bef43073b3c949fe236ae4a;hpb=8273e845426f0187b4ad6c4a1b42286fa09a648f;p=dbsrgits%2FDBIx-Class.git diff --git a/t/resultset/bind_attr.t b/t/resultset/bind_attr.t index 62f4791..a636cfc 100644 --- a/t/resultset/bind_attr.t +++ b/t/resultset/bind_attr.t @@ -1,11 +1,11 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; 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 +16,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 +34,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 +71,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 +112,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;