From e2be648ab41c4380398e4ad2f9d7f70729a1a6b5 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 25 Jul 2024 17:15:03 +0000 Subject: [PATCH] Bug 35044: (QA follow-up): Remove empty additional_field_values entries To test: 1) Follow any of the above test plans to add some additional_field_values entries 2) Run the following SQL: update additional_field_values set value = ''; 3) Run updatedatabase twice. Notice the first time it tells you how many entries were removed. The 2nd time it does nothing. Signed-off-by: Julian Maurice Signed-off-by: Katrin Fischer --- installer/data/mysql/atomicupdate/bug_35044.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_35044.pl b/installer/data/mysql/atomicupdate/bug_35044.pl index 901f38e3be..ef12a83f62 100755 --- a/installer/data/mysql/atomicupdate/bug_35044.pl +++ b/installer/data/mysql/atomicupdate/bug_35044.pl @@ -41,5 +41,14 @@ return { ); say $out "Removed UNIQUE KEY `field_record` (`field_id`,`record_id`) from the additional_field_values table"; } + + my $additional_fields_values = $dbh->selectall_arrayref(q|SELECT * FROM additional_field_values WHERE value = ''|, { Slice => {} }); + my $number_of_entries = scalar @{$additional_fields_values}; + if ( $number_of_entries ){ + for my $afv (@$additional_fields_values) { + $dbh->do(q{DELETE FROM additional_field_values WHERE value = ''}); + } + say $out "Removed $number_of_entries redundant additional_field_values entries with empty value"; + } }, }; -- 2.39.5