View | Details | Raw Unified | Return to bug 23825
Collapse All | Expand All

(-)a/Koha/Object.pm (-5 / +8 lines)
Lines 174-185 sub store { Link Here
174
                    duplicate_id => $+{key}
174
                    duplicate_id => $+{key}
175
                );
175
                );
176
            }
176
            }
177
            elsif( $_->{msg} =~ /Incorrect (?<type>\w+) value: '(?<value>.*)' for column \W?(?<property>\S+)/ ) {
177
            elsif( $_->{msg} =~ /Incorrect (?<type>\w+) value: '(?<value>.*)' for column \W?(?<property>\S+)/ ) { # The optional \W in the regex might be a quote or backtick
178
            # The optional \W in the regex might be a quote or backtick
178
                my $type = $+{type};
179
                my $value = $+{value};
180
                my $property = $+{property};
181
                $property =~ s/['`]//g;
179
                Koha::Exceptions::Object::BadValue->throw(
182
                Koha::Exceptions::Object::BadValue->throw(
180
                    type     => $+{type},
183
                    type     => $type,
181
                    value    => $+{value},
184
                    value    => $value,
182
                    property => $+{property},
185
                    property => $property =~ /(\w+\.\w+)$/ ? $1 : $property, # results in table.column without quotes or backtics
183
                );
186
                );
184
            }
187
            }
185
        }
188
        }
(-)a/t/db_dependent/Koha/Object.t (-2 / +1 lines)
Lines 410-416 subtest 'store() tests' => sub { Link Here
410
            $patron->lastseen('wrong_value')->store;
410
            $patron->lastseen('wrong_value')->store;
411
        } catch {
411
        } catch {
412
            ok( $_->isa('Koha::Exceptions::Object::BadValue'), 'Exception thrown correctly' );
412
            ok( $_->isa('Koha::Exceptions::Object::BadValue'), 'Exception thrown correctly' );
413
            like( $_->property, qr/borrowers\W?\.\W?lastseen/, 'Column should be the expected one' ); # optional \W for quote or backtic
413
            like( $_->property, qr/borrowers\.lastseen/, 'Column should be the expected one' );
414
            is( $_->value, 'wrong_value', 'Value should be the expected one' );
414
            is( $_->value, 'wrong_value', 'Value should be the expected one' );
415
        };
415
        };
416
416
417
- 

Return to bug 23825