From ac6d3358785d3bb84901353d754040454d27b04f Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 18 Oct 2019 09:31:10 +0000 Subject: [PATCH] Bug 23825: Koha/Object.t might fail on a backtick Content-Type: text/plain; charset=utf-8 If the SQL error message contains a backtick instead of a regular quote, the regex for throwing an exception did not work. Example: Incorrect datetime value: 'wrong_value' for column `koha_master`.`borrowers`.`lastseen` Note the backtics where the regex contains a regular quote. This patch makes it more flexible: it allows one \W character before the column name, even optional. Test plan: Run Koha/Object.t Signed-off-by: Marcel de Rooy --- Koha/Object.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/Object.pm b/Koha/Object.pm index 108ea2e52f..bec4a18eaa 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -174,7 +174,8 @@ sub store { duplicate_id => $+{key} ); } - elsif( $_->{msg} =~ /Incorrect (?\w+) value: '(?.*)' for column '(?\w+)'/ ) { + elsif( $_->{msg} =~ /Incorrect (?\w+) value: '(?.*)' for column \W?(?\w+)/ ) { + # The optional \W in the regex might be a quote or backtick Koha::Exceptions::Object::BadValue->throw( type => $+{type}, value => $+{value}, -- 2.11.0