From: Rob Kinyon Date: Wed, 18 Feb 2009 02:50:16 +0000 (+0000) Subject: Added TODO tests for +select and from with as_query X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7f51e1c809f46f903cd829711e4f5c8de96f1779;p=dbsrgits%2FDBIx-Class-Historic.git Added TODO tests for +select and from with as_query --- diff --git a/t/search/subquery.t b/t/search/subquery.t index 4b31ed7..5b54d7a 100644 --- a/t/search/subquery.t +++ b/t/search/subquery.t @@ -10,7 +10,7 @@ use lib qw(t/lib); use DBICTest; use DBIC::SqlMakerTest; -plan tests => 1; +plan tests => 3; my $schema = DBICTest->init_schema(); my $art_rs = $schema->resultset('Artist'); @@ -30,4 +30,49 @@ my $cdrs = $schema->resultset('CD'); ); } +TODO: { + local $TODO = "'+select' doesn't work with as_query yet."; + my $rs = $art_rs->search( + {}, + { + '+select' => [ + $cdrs->search({}, { rows => 1 })->get_column('id')->as_query, + ], + '+as' => [ + 'cdid', + ], + }, + ); + + my $arr = $rs->as_query; + my ($query, @bind) = @{$$arr}; +warn "$query\n"; + is_same_sql_bind( + $query, \@bind, + "SELECT me.artistid, me.name, me.rank, me.charfield, (SELECT id FROM cds LIMIT 1) AS cdid FROM artist me", + [], + ); +} + +TODO: { + local $TODO = "'from' doesn't work with as_query yet."; + my $rs = $cdrs->search( + {}, + { + alias => 'cd2', + from => [ + { cd2 => $cdrs->search({ id => { '>' => 20 } })->as_query }, + ], + }, + ); + + my $arr = $rs->as_query; + my ($query, @bind) = @{$$arr}; + is_same_sql_bind( + $query, \@bind, + "SELECT me.artistid, me.name, me.rank, me.charfield FROM (SELECT me.artistid, me.name, me.rank, me.charfield FROM cds me WHERE id > 20) cd2", + [], + ); +} + __END__