[Bast-commits] r7154 - DBIx-Class/0.08/trunk/lib/DBIx/Class

castaway at dev.catalyst.perl.org castaway at dev.catalyst.perl.org
Thu Jul 30 20:17:33 GMT 2009


Author: castaway
Date: 2009-07-30 20:17:33 +0000 (Thu, 30 Jul 2009)
New Revision: 7154

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
Log:
Mangled Rob's example somewhat, still needs explaining whch circs exactly cause the borken results


Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm	2009-07-30 18:06:04 UTC (rev 7153)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm	2009-07-30 20:17:33 UTC (rev 7154)
@@ -3382,25 +3382,29 @@
 
 =over 4
 
-=item * Prefetch uses the cache to populate the prefetched relationships. This
+=item * 
+
+Prefetch uses the L</cache> to populate the prefetched relationships. This
 may or may not be what you want.
 
-=item * If you specify a condition on a prefetched relationship, ONLY those
+=item * 
+
+If you specify a condition on a prefetched relationship, ONLY those
 rows that match the prefetched condition will be fetched into that relationship.
 This means that adding prefetch to a search() B<may alter> what is returned by
-traversing a relationship. So, if you have C<Foo->has_many(Bar)> and you do
+traversing a relationship. So, if you have C<Artist->has_many(CDs)> and you do
 
-  my $foo_rs = Foo->search({
-      'bars.col1' => $value,
+  my $artist_rs = $schema->resultset('Artist')->search({
+      'cds.year' => 2008,
   }, {
-      join => 'bars',
+      join => 'cds',
   });
 
-  my $count = $foo_rs->first->bars->count;
+  my $count = $artist_rs->first->cds->count;
 
-  my $foo_rs_prefetch = $foo_rs->search( {}, { prefetch => 'bars' } );
+  my $artist_rs_prefetch = $artist_rs->search( {}, { prefetch => 'cds' } );
 
-  my $prefetch_count = $foo_rs_prefetch->first->bars->count;
+  my $prefetch_count = $artist_rs_prefetch->first->cds->count;
 
   cmp_ok( $count, '==', $prefetch_count, "Counts should be the same" );
 




More information about the Bast-commits mailing list