Bug 29138: (QA follow-up) Changes to UPDATE
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 8 Oct 2021 06:30:13 +0000 (06:30 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 12 Oct 2021 08:52:44 +0000 (10:52 +0200)
Move the condition to the WHERE clause, using COALESCE to
prevent mysqlism (IFNULL) and strings for strict SQL.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested on NULL, 0, 1, 2, no, yes. (2 and yes become 0 too. Fine.)
Tested strict sql mode: no truncated incorrect DOUBLE value-error anymore.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
installer/data/mysql/atomicupdate/Bug_29138.pl

index 731099f..8261ce1 100755 (executable)
@@ -6,12 +6,9 @@ return {
     up => sub {
         my ($args) = @_;
         my ($dbh, $out) = @$args{qw(dbh out)};
-        # Do you stuffs here
         $dbh->do(q{
-                UPDATE systempreferences SET value= IF(value='no',0,1)
-                WHERE variable = 'LoadSearchHistoryToTheFirstLoggedUser';
-                });
-        # Print useful stuff here
-        say $out "LoadSearchHistoryToTheFirstLoggedUser updated";
+            UPDATE systempreferences SET value='0'
+            WHERE variable='LoadSearchHistoryToTheFirstLoggedUser' AND COALESCE(value,'0')<>'1';
+        });
     },
 }