@@ -, +, @@ --- Koha/Object.pm | 13 ++++++++----- t/db_dependent/Koha/Object.t | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) --- a/Koha/Object.pm +++ a/Koha/Object.pm @@ -174,12 +174,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 ); } } --- a/t/db_dependent/Koha/Object.t +++ a/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' ); }; --