[Bast-commits] r6033 - DBIx-Class/0.08/trunk/t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu Apr 30 06:53:51 GMT 2009


Author: ribasushi
Date: 2009-04-30 07:53:51 +0100 (Thu, 30 Apr 2009)
New Revision: 6033

Modified:
   DBIx-Class/0.08/trunk/t/76select.t
Log:
Add tests for r6002

Modified: DBIx-Class/0.08/trunk/t/76select.t
===================================================================
--- DBIx-Class/0.08/trunk/t/76select.t	2009-04-29 23:53:08 UTC (rev 6032)
+++ DBIx-Class/0.08/trunk/t/76select.t	2009-04-30 06:53:51 UTC (rev 6033)
@@ -9,7 +9,7 @@
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 21;
+plan tests => 24;
 
 my $rs = $schema->resultset('CD')->search({},
     {
@@ -134,3 +134,68 @@
 lives_ok(sub {
   $rs->first->artist->get_column('name')
 }, 'columns 3rd rscolumn present');
+
+
+$rs = $schema->resultset('CD')->search({'tracks.position' => { -in => [2] } },
+  {
+    join => 'tracks',
+    columns => [qw/me.cdid me.title/],
+    '+select' => ['tracks.position'],
+    '+as' => ['track_position'],
+
+    # get a hashref of CD1 only (the first with a second track)
+    result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+    order_by => 'cdid',
+    rows => 1,
+  }
+);
+
+is_deeply (
+  $rs->single,
+  {
+    cdid => 1,
+    track_position => 2,
+    title => 'Spoonful of bees',
+  },
+  'limited prefetch via column works on a multi-relationship',
+);
+
+my $sub_rs = $rs->search ({},
+  {
+    columns => [qw/artist tracks.trackid/],    # columns should not be merged but override $rs columns
+    '+select' => ['tracks.title'],
+    '+as' => ['tracks.title'],
+  }
+);
+
+is_deeply (
+  $sub_rs->single,
+  {
+    artist => 1,
+    track_position => 2,
+    tracks =>
+      {
+        trackid => 17,
+        title => 'Apiary',
+      },
+  },
+  'columns/select/as fold properly on sub-searches',
+);
+
+TODO: {
+  local $TODO = "Multi-collapsing still doesn't work right - HRI should be getting an arrayref, not an individual hash";
+  is_deeply (
+    $sub_rs->single,
+    {
+      artist => 1,
+      track_position => 2,
+      tracks => [
+        {
+          trackid => 17,
+          title => 'Apiary',
+        },
+      ],
+    },
+    'columns/select/as fold properly on sub-searches',
+  );
+}




More information about the Bast-commits mailing list