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