X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FOrdered.pm;h=b6c4177df63e823a0681f90e7f9d7a6188065495;hb=0353535690d973b3ad10e1476d5d0c5692655d11;hp=7842a4059d7913e8be0c9bff3f0b5e571ec03ece;hpb=48580715af3072905f2c71dc27e7f70f21a11338;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index 7842a40..b6c4177 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -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 @@ -797,15 +795,15 @@ sub _shift_siblings { if (grep { $_ eq $position_column } ( map { @$_ } (values %{{ $rsrc->unique_constraints }} ) ) ) { - my @pcols = $rsrc->primary_columns; + my @pcols = $rsrc->_pri_cols; my $cursor = $shift_rs->search ({}, { order_by => { "-$ord", $position_column }, columns => \@pcols } )->cursor; my $rs = $self->result_source->resultset; - while (my @pks = $cursor->next ) { - + my @all_pks = $cursor->all; + while (my $pks = shift @all_pks) { my $cond; for my $i (0.. $#pcols) { - $cond->{$pcols[$i]} = $pks[$i]; + $cond->{$pcols[$i]} = $pks->[$i]; } $rs->search($cond)->update ({ $position_column => \ "$position_column $op 1" } ); @@ -943,9 +941,23 @@ __END__ =head1 CAVEATS +=head2 Resultset Methods + +Note that all Insert/Create/Delete overrides are happening on +L methods only. If you use the +L versions of +L or +L, all logic present in this +module will be bypassed entirely (possibly resulting in a broken +order-tree). Instead always use the +L and +L methods, which will +invoke the corresponding L 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 or L, depending if there are already some items in the current group. The space of time between the