From: Peter Rabbitson Date: Wed, 6 May 2009 15:40:31 +0000 (+0000) Subject: Merge 'subquery' into 'count_distinct' X-Git-Tag: v0.08103~101^2~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=27051402fad84eb7c783b73f8ade4e124a6a6cae;p=dbsrgits%2FDBIx-Class.git Merge 'subquery' into 'count_distinct' Add subquery/from test by michaelr (copied from subquery branch r5742) --- 27051402fad84eb7c783b73f8ade4e124a6a6cae diff --cc t/search/subquery.t index e99192b,b5e0548..c2a1bff --- a/t/search/subquery.t +++ b/t/search/subquery.t @@@ -7,7 -7,12 +7,7 @@@ use Data::Dumper use Test::More; - plan ( tests => 7 ); -BEGIN { - eval "use SQL::Abstract 1.49"; - plan $@ - ? ( skip_all => "Needs SQLA 1.49+" ) - : ( tests => 8 ); -} ++plan ( tests => 8 ); use lib qw(t/lib); use DBICTest; @@@ -168,4 -167,24 +168,24 @@@ my $cdrs = $schema->resultset('CD') ); } + { + my $rs = $cdrs->search( + {}, + { + alias => 'cd2', + from => [ + { cd2 => $cdrs->search({ title => 'Thriller' })->as_query }, + ], + }, + ); + + my $arr = $rs->as_query; + my ($query, @bind) = @{$$arr}; + is_same_sql_bind( + $query, \@bind, - "SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE title = 'Thriller') cd2", - [], ++ "(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE title = ?) cd2)", ++ ['Thriller'], + ); + } + __END__