=cut
sub siblings {
my $self = shift;
- return $self->_siblings->search ({}, { order_by => $self->position_column } );
+ return $self->_siblings->search ({}, {
+ order_by => [ $self->position_column, $self->grouping_column ],
+ });
}
=head2 previous_siblings
sub previous_sibling {
my $self = shift;
my $position_column = $self->position_column;
+ my $grouping_column = $self->grouping_column;
my $psib = $self->previous_siblings->search(
{},
- { rows => 1, order_by => { '-desc' => $position_column } },
+ { rows => 1, order_by => [
+ { '-desc' => $position_column },
+ $grouping_column,
+ ],
+ },
)->single;
return defined $psib ? $psib : 0;
sub first_sibling {
my $self = shift;
my $position_column = $self->position_column;
+ my $grouping_column = $self->grouping_column;
my $fsib = $self->previous_siblings->search(
{},
- { rows => 1, order_by => { '-asc' => $position_column } },
+ { rows => 1, order_by => [
+ { '-asc' => $position_column },
+ $grouping_column,
+ ],
+ },
)->single;
return defined $fsib ? $fsib : 0;
sub next_sibling {
my $self = shift;
my $position_column = $self->position_column;
+ my $grouping_column = $self->grouping_column;
my $nsib = $self->next_siblings->search(
{},
- { rows => 1, order_by => { '-asc' => $position_column } },
+ { rows => 1, order_by => [
+ { '-asc' => $position_column },
+ $grouping_column,
+ ],
+ },
)->single;
return defined $nsib ? $nsib : 0;
sub last_sibling {
my $self = shift;
my $position_column = $self->position_column;
+ my $grouping_column = $self->grouping_column;
my $lsib = $self->next_siblings->search(
{},
- { rows => 1, order_by => { '-desc' => $position_column } },
+ { rows => 1, order_by => [
+ { '-desc' => $position_column },
+ $grouping_column,
+ ],
+ },
)->single;
return defined $lsib ? $lsib : 0;
sub _last_sibling_posval {
my $self = shift;
my $position_column = $self->position_column;
+ my $grouping_column = $self->grouping_column;
my $cursor = $self->next_siblings->search(
{},
- { rows => 1, order_by => { '-desc' => $position_column }, select => $position_column },
+ { rows => 1, order_by => [
+ { '-desc' => $position_column },
+ $grouping_column
+ ], select => $position_column },
)->cursor;
my ($pos) = $cursor->next;