add_relationship, relationship_info, relationships moved to ResultSource
[dbsrgits/DBIx-Class.git] / t / run / 16joins.tl
index e9aabc9..cab0a93 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 22 );
+        : ( tests => 23 );
 }
 
 # test the abstract join => SQL generator
@@ -81,6 +81,13 @@ cmp_ok( $rs->count, '==', 1, "Single record in resultset");
 
 is($rs->first->title, 'Come Be Depressed With Us', 'Correct record returned');
 
+# when using join attribute, make sure slice()ing all objects has same count as all()
+$rs = DBICTest->class("CD")->search(
+    { 'artist' => 1 },
+    { join => [qw/artist/], order_by => 'artist.name' }
+);
+cmp_ok( scalar $rs->all, '==', scalar $rs->slice(0, $rs->count - 1), 'slice() with join has same count as all()' );
+
 $rs = DBICTest->class("Artist")->search(
         { 'liner_notes.notes' => 'Kill Yourself!' },
         { join => { 'cds' => 'liner_notes' } });
@@ -89,17 +96,6 @@ cmp_ok( $rs->count, '==', 1, "Single record in resultset");
 
 is($rs->first->name, 'We Are Goth', 'Correct record returned');
 
-DBICTest::Schema::CD->add_relationship(
-    artist => 'DBICTest::Schema::Artist',
-    { 'foreign.artistid' => 'self.artist' },
-    { accessor => 'filter' },
-);
-
-DBICTest::Schema::CD->add_relationship(
-    liner_notes => 'DBICTest::Schema::LinerNotes',
-    { 'foreign.liner_id' => 'self.cdid' },
-    { join_type => 'LEFT', accessor => 'single' });
-
 $rs = DBICTest->class("CD")->search(
            { 'artist.name' => 'Caterwauler McCrae' },
            { prefetch => [ qw/artist liner_notes/ ],