Add sortorder to filesets

This commit is contained in:
Peter J. Holzer 2021-07-25 12:22:27 +02:00
parent 24932a63ac
commit 88f226757d
1 changed files with 5 additions and 1 deletions

View File

@ -113,7 +113,11 @@ sub new {
$self->{instances_part_size} = 10_000_000;
$self->adjust_partitions;
$self->{targets} = $self->{dbh}->selectall_arrayref("select * from filesets", { Slice => {} });
# Order by ascending sort order with nulls last:
# MySQL considers NULL to be smaller than any number, so negate the numbers
# (making the largest the smallest) and then sort descending.
# Idea from https://www.designcise.com/web/tutorial/how-to-order-null-values-first-or-last-in-mysql
$self->{targets} = $self->{dbh}->selectall_arrayref("select * from filesets order by -sortorder desc", { Slice => {} });
if ($opt->{filesets}) {
$self->{targets} =
[