X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FOrdered.pm;h=c9579a8fcef7b6f22e5cc3016f35c504f816d0bd;hb=854929cb5def53f094d9dd7e17a093838121e665;hp=5f17790a9a884a3dfd162080a238f1c0900a416f;hpb=69cd8a7fcceed892f3bbd6cfba5804776033a85b;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index 5f17790..c9579a8 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -127,7 +127,7 @@ __PACKAGE__->mk_classdata( 'grouping_column' ); This method specifies a value of L which B 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. @@ -797,15 +797,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" } ); @@ -921,7 +921,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 like you normally would, as it will get confused by the wrong data before @@ -956,14 +956,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. 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