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