Multiple optimizations of $rs->populate
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Ordered.pm
index 409159e..b6c4177 100644 (file)
@@ -127,7 +127,7 @@ __PACKAGE__->mk_classdata( 'grouping_column' );
 This method specifies a value of L</position_column> which B<would
 never be assigned to a row> during normal operation. When
 a row is moved, its position is set to this value temporarily, so
-that any unique constrainst can not be violated. This value defaults
+that any unique constraints can not be violated. This value defaults
 to 0, which should work for all cases except when your positions do
 indeed start from 0.
 
@@ -628,11 +628,10 @@ sub update {
         }
 
         my @res;
-        my $want = wantarray();
-        if (not defined $want) {
+        if (not defined wantarray) {
             $self->next::method( \%upd, @_ );
         }
-        elsif ($want) {
+        elsif (wantarray) {
             @res = $self->next::method( \%upd, @_ );
         }
         else {
@@ -640,7 +639,7 @@ sub update {
         }
 
         $guard->commit;
-        return $want ? @res : $res[0];
+        return wantarray ? @res : $res[0];
     }
 }
 
@@ -660,11 +659,10 @@ sub delete {
     $self->move_last;
 
     my @res;
-    my $want = wantarray();
-    if (not defined $want) {
+    if (not defined wantarray) {
         $self->next::method( @_ );
     }
-    elsif ($want) {
+    elsif (wantarray) {
         @res = $self->next::method( @_ );
     }
     else {
@@ -672,7 +670,7 @@ sub delete {
     }
 
     $guard->commit;
-    return $want ? @res : $res[0];
+    return wantarray ? @res : $res[0];
 }
 
 =head1 METHODS FOR EXTENDING ORDERED
@@ -801,7 +799,7 @@ sub _shift_siblings {
         my $cursor = $shift_rs->search ({}, { order_by => { "-$ord", $position_column }, columns => \@pcols } )->cursor;
         my $rs = $self->result_source->resultset;
 
-        my @all_pks = $cusrsor->all;
+        my @all_pks = $cursor->all;
         while (my $pks = shift @all_pks) {
           my $cond;
           for my $i (0.. $#pcols) {
@@ -921,7 +919,7 @@ module to update positioning values in isolation (i.e. without
 triggering any of the positioning integrity code).
 
 Some day you might get confronted by datasets that have ambiguous
-positioning data (i.e. duplicate position values within the same group,
+positioning data (e.g. duplicate position values within the same group,
 in a table without unique constraints). When manually fixing such data
 keep in mind that you can not invoke L<DBIx::Class::Row/update> like
 you normally would, as it will get confused by the wrong data before
@@ -943,9 +941,23 @@ __END__
 
 =head1 CAVEATS
 
+=head2 Resultset Methods
+
+Note that all Insert/Create/Delete overrides are happening on
+L<DBIx::Class::Row> methods only. If you use the
+L<DBIx::Class::ResultSet> versions of
+L<update|DBIx::Class::ResultSet/update> or
+L<delete|DBIx::Class::ResultSet/delete>, all logic present in this
+module will be bypassed entirely (possibly resulting in a broken
+order-tree). Instead always use the
+L<update_all|DBIx::Class::ResultSet/update_all> and
+L<delete_all|DBIx::Class::ResultSet/delete_all> methods, which will
+invoke the corresponding L<row|DBIx::Class::Row> method on every
+member of the given resultset.
+
 =head2 Race Condition on Insert
 
-If a position is not specified for an insert than a position 
+If a position is not specified for an insert, a position
 will be chosen based either on L</_initial_position_value> or
 L</_next_position_value>, depending if there are already some
 items in the current group. The space of time between the
@@ -956,14 +968,14 @@ will prevent such race conditions going undetected.
 
 =head2 Multiple Moves
 
-Be careful when issueing move_* methods to multiple objects.  If 
+Be careful when issuing move_* methods to multiple objects.  If 
 you've pre-loaded the objects then when you move one of the objects 
 the position of the other object will not reflect their new value 
 until you reload them from the database - see
 L<DBIx::Class::Row/discard_changes>.
 
 There are times when you will want to move objects as groups, such 
-as changeing the parent of several objects at once - this directly 
+as changing the parent of several objects at once - this directly 
 conflicts with this problem.  One solution is for us to write a 
 ResultSet class that supports a parent() method, for example.  Another 
 solution is to somehow automagically modify the objects that exist