Merge 'count_rs' into 'trunk'
Peter Rabbitson [Sat, 20 Jun 2009 21:30:23 +0000 (21:30 +0000)]
r6737@Thesaurus (orig r6736):  ribasushi | 2009-06-20 12:39:34 +0200
new branch to streamline count() and introduce count_rs()
r6738@Thesaurus (orig r6737):  ribasushi | 2009-06-20 12:44:09 +0200
Add count_rs, move the code back from DBI - leave only sql specific hooks
r6739@Thesaurus (orig r6738):  ribasushi | 2009-06-20 12:54:11 +0200
Test count_rs
r6742@Thesaurus (orig r6741):  ribasushi | 2009-06-20 23:30:10 +0200
More tests and a really working count_rs

lib/DBIx/Class/ResultSet.pm

index b4fc281..f0a5790 100644 (file)
@@ -1619,8 +1619,9 @@ In void context, C<insert_bulk> in L<DBIx::Class::Storage::DBI> is used
 to insert the data, as this is a faster method.
 
 Otherwise, each set of data is inserted into the database using
-L<DBIx::Class::ResultSet/create>, and a arrayref of the resulting row
-objects is returned.
+L<DBIx::Class::ResultSet/create>, and the resulting objects are
+accumulated into an array. The array itself, or an array reference
+is returned depending on scalar or list context.
 
 Example:  Assuming an Artist Class that has many CDs Classes relating:
 
@@ -1686,7 +1687,7 @@ sub populate {
     foreach my $item (@$data) {
       push(@created, $self->create($item));
     }
-    return @created;
+    return wantarray ? @created : \@created;
   } else {
     my ($first, @rest) = @$data;