From ae7e70a31e15f37bf667b95caea70c50247419f6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 1 May 2020 14:12:09 +0100 Subject: [PATCH] Bug 23185: (QA follow-up) Semantics, split fields and options This patch improves the semantics of the update routine to more clearly separate the 'fields' we're modifying from the 'options' we wish to apply to the modification. Signed-off-by: Victor Grousset/tuxayo --- Koha/Objects.pm | 8 ++++---- t/db_dependent/Koha/Objects.t | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 7512f2616f..94271928b1 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -199,9 +199,9 @@ sub delete { =cut sub update { - my ($self, $params) = @_; + my ($self, $fields, $options) = @_; - my $no_triggers = delete $params->{no_triggers}; + my $no_triggers = $options->{no_triggers}; if ( !$no_triggers @@ -212,14 +212,14 @@ sub update { my $objects_updated; $self->_resultset->result_source->schema->txn_do( sub { while ( my $o = $self->next ) { - $o->update($params); + $o->update($fields); $objects_updated++; } }); return $objects_updated; } - return $self->_resultset->update($params); + return $self->_resultset->update($fields); } =head3 single diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index beeac1ba66..96a6bc6d30 100644 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -995,7 +995,7 @@ subtest 'Return same values as DBIx::Class' => sub { $patrons_us->update({ surname => 'foo' }); # Koha::Patron->store is supposed to uppercase the surnames is( $patrons_us->search({ surname => 'FOO' })->count, 2, 'Koha::Patron->store is hit' ); - $patrons_us->update({ surname => 'foo', no_triggers => 1 }); # The surnames won't be uppercase as we won't hit Koha::Patron->store + $patrons_us->update({ surname => 'foo' }, { no_triggers => 1 }); # The surnames won't be uppercase as we won't hit Koha::Patron->store is( $patrons_us->search({ surname => 'foo' })->count, 2, 'Koha::Patron->store is not hit'); }; -- 2.26.2