Bugzilla – Attachment 55654 Details for
Bug 16961
Add the Koha::Objects->update method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 16961: Add Koha::Objects->update
PASSED-QA-Bug-16961-Add-KohaObjects-update.patch (text/plain), 2.77 KB, created by
Katrin Fischer
on 2016-09-18 14:45:01 UTC
(
hide
)
Description:
[PASSED QA] Bug 16961: Add Koha::Objects->update
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2016-09-18 14:45:01 UTC
Size:
2.77 KB
patch
obsolete
>From 056d5ef95a8b46f0177f7f34bcb3b5c02de85027 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 22 Jul 2016 13:56:36 +0100 >Subject: [PATCH] [PASSED QA] Bug 16961: Add Koha::Objects->update > >In order to update several rows in a single query, we need this new >method. > >Test plan: >Confirm that the changes in Objects.t make sense and that the tests >pass. > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> >Test passed successfully > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >--- > Koha/Objects.pm | 13 +++++++++++++ > t/db_dependent/Koha/Objects.t | 17 ++++++++++++++++- > 2 files changed, 29 insertions(+), 1 deletion(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index c365e7f..97436ad 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -234,6 +234,19 @@ sub _wrap { > return @objects; > } > >+=head3 update >+ >+ Koha::Objects->search({ $key => $value})->update( \%values ); >+ >+Sets the specified columns in the resultset to the supplied values in a single query. >+ >+=cut >+ >+sub update { >+ my ( $self, $params ) = @_; >+ return $self->_resultset()->update($params); >+} >+ > =head3 Koha::Objects->_resultset > > Returns the internal resultset or creates it if undefined >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index b92239a..3551caa 100644 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -19,9 +19,10 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > > use Koha::Authority::Types; >+use Koha::Cities; > use Koha::Patrons; > use Koha::Database; > >@@ -36,5 +37,19 @@ my @columns = Koha::Patrons->columns; > my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns; > is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' ); > >+subtest 'update' => sub { >+ plan tests => 2; >+ my $builder = t::lib::TestBuilder->new; >+ $builder->build( { source => 'City', value => { city_country => 'UK' } } ); >+ $builder->build( { source => 'City', value => { city_country => 'UK' } } ); >+ $builder->build( { source => 'City', value => { city_country => 'UK' } } ); >+ $builder->build( { source => 'City', value => { city_country => 'France' } } ); >+ $builder->build( { source => 'City', value => { city_country => 'France' } } ); >+ $builder->build( { source => 'City', value => { city_country => 'Germany' } } ); >+ Koha::Cities->search( { city_country => 'UK' } )->update( { city_country => 'EU' } ); >+ is( Koha::Cities->search( { city_country => 'EU' } )->count, 3, 'Koha::Objects->update should have updated the 3 rows' ); >+ is( Koha::Cities->search( { city_country => 'UK' } )->count, 0, 'Koha::Objects->update should have updated the 3 rows' ); >+}; >+ > $schema->storage->txn_rollback; > 1; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16961
:
53645
|
53655
| 55654