}
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 {
}
$guard->commit;
- return $want ? @res : $res[0];
+ return wantarray ? @res : $res[0];
}
}
$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 {
}
$guard->commit;
- return $want ? @res : $res[0];
+ return wantarray ? @res : $res[0];
}
=head1 METHODS FOR EXTENDING ORDERED
Shifts all siblings with B<positions values> in the range @between
(inclusive) by one position as specified by $direction (left if < 0,
right if > 0). By default simply increments/decrements each
-L<position_column> value by 1, doing so in a way as to not violate
+L</position_column> value by 1, doing so in a way as to not violate
any existing constraints.
Note that if you override this method and have unique constraints
-including the L<position_column> the shift is not a trivial task.
+including the L</position_column> the shift is not a trivial task.
Refer to the implementation source of the default method for more
information.
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" } );
=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