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 <victor@tuxayo.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2020-05-01 14:12:09 +01:00
parent 6235d0cfa1
commit 633befb5f0
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
2 changed files with 5 additions and 5 deletions

View file

@ -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

View file

@ -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');
};