[Bast-commits] r5515 - DBIx-Class/0.08/branches/subquery/t/search
robkinyon at dev.catalyst.perl.org
robkinyon at dev.catalyst.perl.org
Wed Feb 18 02:50:17 GMT 2009
Author: robkinyon
Date: 2009-02-18 02:50:16 +0000 (Wed, 18 Feb 2009)
New Revision: 5515
Modified:
DBIx-Class/0.08/branches/subquery/t/search/subquery.t
Log:
Added TODO tests for +select and from with as_query
Modified: DBIx-Class/0.08/branches/subquery/t/search/subquery.t
===================================================================
--- DBIx-Class/0.08/branches/subquery/t/search/subquery.t 2009-02-18 02:37:09 UTC (rev 5514)
+++ DBIx-Class/0.08/branches/subquery/t/search/subquery.t 2009-02-18 02:50:16 UTC (rev 5515)
@@ -10,7 +10,7 @@
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 @@
);
}
+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__
More information about the Bast-commits
mailing list