[Bast-commits] r8411 - DBIx-Class/0.08/branches/chaining_fixes/t/search

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Fri Jan 22 10:19:40 GMT 2010


Author: ribasushi
Date: 2010-01-22 10:19:40 +0000 (Fri, 22 Jan 2010)
New Revision: 8411

Added:
   DBIx-Class/0.08/branches/chaining_fixes/t/search/select_chains.t
Log:
Chaining POC test

Added: DBIx-Class/0.08/branches/chaining_fixes/t/search/select_chains.t
===================================================================
--- DBIx-Class/0.08/branches/chaining_fixes/t/search/select_chains.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/chaining_fixes/t/search/select_chains.t	2010-01-22 10:19:40 UTC (rev 8411)
@@ -0,0 +1,60 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+use lib qw(t/lib);
+use DBIC::SqlMakerTest;
+use DBICTest;
+
+
+my $schema = DBICTest->init_schema();
+
+my @chain = (
+  {
+    columns     => [ 'cdid' ],
+    '+select'   => [ { lower => 'title' }, 'genreid' ],
+    '+as'       => [ qw/title_lc genreid/ ],
+  } => 'SELECT me.cdid, LOWER( title ), me.genreid FROM cd me',
+
+  {
+    '+columns'  => [ { max_year => { max => 'me.year' }}, ],
+    '+select'   => [ { count => 'me.cdid' }, ],
+    '+as'       => [ 'cnt' ],
+  } => 'SELECT me.cdid, MAX( me.year ), LOWER( title ), me.genreid, COUNT( me.cdid ) FROM cd me',
+
+  {
+    select      => [ { min => 'me.cdid' }, ],
+    as          => [ 'min_id' ],
+  } => 'SELECT MIN( me.cdid ) FROM cd me',
+
+  {
+    '+columns' => [ { cnt => { count => 'cdid' } } ],
+  } => 'SELECT COUNT ( cdid ), MIN( me.cdid ) FROM cd me',
+
+  {
+    columns => [ 'year' ],
+  } => 'SELECT me.year FROM cd me',
+);
+
+my $rs = $schema->resultset('CD');
+
+my $testno = 1;
+while (@chain) {
+  my $attrs = shift @chain;
+  my $sql = shift @chain;
+
+  $rs = $rs->search ({}, $attrs);
+
+  is_same_sql_bind (
+    $rs->as_query,
+    "x( $sql )", # the x-es are here until SQLA is fixed
+    [],
+    "Test $testno of SELECT assembly ok",
+  );
+
+  $testno++;
+}
+
+done_testing;
\ No newline at end of file




More information about the Bast-commits mailing list