Bug 29138: (QA follow-up) Changes to UPDATE

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>
This commit is contained in:
Marcel de Rooy 2021-10-08 06:30:13 +00:00 committed by Jonathan Druart
parent 701bce97f5
commit bfb403dfb4
1 changed files with 3 additions and 6 deletions

View File

@ -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';
});
},
}