From e0b2cb80fb08c9c7b881e8b43c75576eedd0c98a Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Mon, 28 Oct 2019 09:00:26 +0000
Subject: [PATCH] Bug 23825: (QA follow-up) Remove database name
Content-Type: text/plain; charset=utf-8

As requested on comment15.

Test plan:
Run t/db_dependent/Koha/Object.t again

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
---
 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 f764e5ec0b..a92e870c40 100644
--- a/Koha/Object.pm
+++ b/Koha/Object.pm
@@ -174,12 +174,15 @@ sub store {
                     duplicate_id => $+{key}
                 );
             }
-            elsif( $_->{msg} =~ /Incorrect (?<type>\w+) value: '(?<value>.*)' for column \W?(?<property>\S+)/ ) {
-            # The optional \W in the regex might be a quote or backtick
+            elsif( $_->{msg} =~ /Incorrect (?<type>\w+) value: '(?<value>.*)' for column \W?(?<property>\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 2a54225c97..af723528c6 100755
--- a/t/db_dependent/Koha/Object.t
+++ b/t/db_dependent/Koha/Object.t
@@ -410,7 +410,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.11.0