Merge 'trunk' into 'DBIx-Class-current'
Brandon L. Black [Thu, 3 May 2007 03:03:06 +0000 (03:03 +0000)]
r30777@brandon-blacks-computer (orig r3224):  nigel | 2007-05-02 09:58:45 -0500
Documented use of cursor->next for fast but uncomfortable data fetches
r30778@brandon-blacks-computer (orig r3225):  blblack | 2007-05-02 22:02:14 -0500
revert part of 3220, apparently it is breaking cloning behavior in subtle ways that we have no tests for

lib/DBIx/Class/Cursor.pm
lib/DBIx/Class/Manual/Cookbook.pod
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/Storage/DBI/Cursor.pm

index 3c55b69..ded8b56 100644 (file)
@@ -38,7 +38,8 @@ sub new {
 
 =head2 next
 
-Virtual method. Advances the cursor to the next row.
+Virtual method. Advances the cursor to the next row. Returns an array of
+column values (the result of L<DBI/fetchrow_array> method).
 
 =cut
 
index 369b89e..4dec7ae 100644 (file)
@@ -1121,6 +1121,22 @@ To do this simply use L<DBIx::Class::ResultClass::HashRefInflator>.
   
 Wasn't that easy?
   
+=head2 Get raw data for blindingly fast results
+
+If the C<inflate_result> solution above is not fast enough for you, you
+can use a DBIx::Class to return values exactly as they come out of the
+data base with none of the convenience methods wrapped round them.
+
+This is used like so:-
+
+  my $cursor = $rs->cursor
+  while (my @vals = $cursor->next) {
+      # use $val[0..n] here
+  }
+
+You will need to map the array offsets to particular columns (you can
+use the I<select> attribute of C<search()> to force ordering).
+
 =head2 Want to know if find_or_create found or created a row?
 
 Just use C<find_or_new> instead, then check C<in_storage>:
index 2913a2f..223dbd3 100644 (file)
@@ -97,13 +97,17 @@ sub register_source {
 
   %$source = %{ $source->new( { %$source, source_name => $moniker }) };
 
-  $self->source_registrations->{$moniker} = $source;
+  my %reg = %{$self->source_registrations};
+  $reg{$moniker} = $source;
+  $self->source_registrations(\%reg);
 
   $source->schema($self);
 
   weaken($source->{schema}) if ref($self);
   if ($source->result_class) {
-    $self->class_mappings->{$source->result_class} = $moniker;
+    my %map = %{$self->class_mappings};
+    $map{$source->result_class} = $moniker;
+    $self->class_mappings(\%map);
   }
 }
 
index c9dedf6..e46c1b6 100644 (file)
@@ -59,7 +59,8 @@ sub new {
 
 =back
 
-Advances the cursor to the next row and returns an arrayref of column values.
+Advances the cursor to the next row and returns an array of column
+values (the result of L<DBI/fetchrow_array> method).
 
 =cut