From 56d98b914d1c1ed27b44baa09155a9e389faff17 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 28 Oct 2019 09:00:26 +0000 Subject: [PATCH] Bug 23825: (QA follow-up) Remove database name As requested on comment15. Test plan: Run t/db_dependent/Koha/Object.t again Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize (cherry picked from commit e5cdf8854473d6c766816355d080376afa1766d5) Signed-off-by: Victor Grousset/tuxayo --- Koha/Object.pm | 13 ++++++++----- t/db_dependent/Koha/Object.t | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Koha/Object.pm b/Koha/Object.pm index d1ce135540..883cb1ca84 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -175,12 +175,15 @@ sub store { duplicate_id => $+{key} ); } - elsif( $_->{msg} =~ /Incorrect (?\w+) value: '(?.*)' for column \W?(?\S+)/ ) { - # The optional \W in the regex might be a quote or backtick + elsif( $_->{msg} =~ /Incorrect (?\w+) value: '(?.*)' for column \W?(?\S+)/ ) { # The optional \W in the regex might be a quote or backtick + my $type = $+{type}; + my $value = $+{value}; + my $property = $+{property}; + $property =~ s/['`]//g; Koha::Exceptions::Object::BadValue->throw( - type => $+{type}, - value => $+{value}, - property => $+{property}, + type => $type, + value => $value, + property => $property =~ /(\w+\.\w+)$/ ? $1 : $property, # results in table.column without quotes or backtics ); } } diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index 1f4d3164c7..cf725ce9c6 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -358,7 +358,7 @@ subtest 'store() tests' => sub { $patron->lastseen('wrong_value')->store; } catch { ok( $_->isa('Koha::Exceptions::Object::BadValue'), 'Exception thrown correctly' ); - like( $_->property, qr/borrowers\W?\.\W?lastseen/, 'Column should be the expected one' ); # optional \W for quote or backtic + like( $_->property, qr/borrowers\.lastseen/, 'Column should be the expected one' ); is( $_->value, 'wrong_value', 'Value should be the expected one' ); }; -- 2.39.5