From 88f226757dabf85f9ff3fc1a39d45f92bc491d16 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sun, 25 Jul 2021 12:22:27 +0200 Subject: [PATCH] Add sortorder to filesets --- lib/Simba/CA.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Simba/CA.pm b/lib/Simba/CA.pm index 428bc16..8459dfc 100644 --- a/lib/Simba/CA.pm +++ b/lib/Simba/CA.pm @@ -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} = [