From: Rob Kinyon Date: Wed, 18 Feb 2009 02:37:09 +0000 (+0000) Subject: Moved the actual subquery test to a new subquery testfile X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbbd793984d9850d356d5ebb264ce577f5b98b4e;p=dbsrgits%2FDBIx-Class-Historic.git Moved the actual subquery test to a new subquery testfile --- diff --git a/t/resultset/as_query.t b/t/resultset/as_query.t index 8df7e7d..2813b1d 100644 --- a/t/resultset/as_query.t +++ b/t/resultset/as_query.t @@ -10,7 +10,7 @@ use lib qw(t/lib); use DBICTest; use DBIC::SqlMakerTest; -plan tests => 5; +plan tests => 4; my $schema = DBICTest->init_schema(); my $art_rs = $schema->resultset('Artist'); @@ -65,19 +65,4 @@ my $rscol = $art_rs->get_column( 'charfield' ); ); } -# This is an actual subquery. -{ - my $cdrs2 = $cdrs->search({ - artist_id => { 'in' => $art_rs->search({}, { rows => 1 })->get_column( 'id' )->as_query }, - }); - - my $arr = $cdrs2->as_query; - my ($query, @bind) = @{$$arr}; - is_same_sql_bind( - $query, \@bind, - "SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE artist_id IN ( SELECT id FROM artist me WHERE ( rank = ? ) AND ( name = ? ) LIMIT 1 )", - [ [ rank => 2 ], [ name => 'Billy Joel' ] ], - ); -} - __END__ diff --git a/t/search/subquery.t b/t/search/subquery.t new file mode 100644 index 0000000..4b31ed7 --- /dev/null +++ b/t/search/subquery.t @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +use strict; +use warnings FATAL => 'all'; + +use Data::Dumper; + +use Test::More; +use lib qw(t/lib); +use DBICTest; +use DBIC::SqlMakerTest; + +plan tests => 1; + +my $schema = DBICTest->init_schema(); +my $art_rs = $schema->resultset('Artist'); +my $cdrs = $schema->resultset('CD'); + +{ + my $cdrs2 = $cdrs->search({ + artist_id => { 'in' => $art_rs->search({}, { rows => 1 })->get_column( 'id' )->as_query }, + }); + + my $arr = $cdrs2->as_query; + my ($query, @bind) = @{$$arr}; + is_same_sql_bind( + $query, \@bind, + "SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE artist_id IN ( SELECT id FROM artist me LIMIT 1 )", + [], + ); +} + +__END__