Bugzilla – Attachment 53380 Details for
Bug 16889
Move the ::columns subroutines to Koha::Objects->columns
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16889: Add Koha::Objects->columns
Bug-16889-Add-KohaObjects-columns.patch (text/plain), 2.00 KB, created by
Kyle M Hall (khall)
on 2016-07-13 15:44:58 UTC
(
hide
)
Description:
Bug 16889: Add Koha::Objects->columns
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-07-13 15:44:58 UTC
Size:
2.00 KB
patch
obsolete
>From 99f3d640d3bb137f4c1bf77558ab457f21c62604 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 9 Jul 2016 14:32:40 +0100 >Subject: [PATCH] Bug 16889: Add Koha::Objects->columns > >Currently we have 3 subroutines to retrieve the columns of tables: >C4::Members::columns, C4::Items::columns and >C4::Items::biblioitems_columns. >It is easier to have a Koha::Objects->columns method to provide the >different classes to retrieve their related column names. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Objects.pm | 15 +++++++++++++++ > t/db_dependent/Koha/Objects.t | 7 ++++++- > 2 files changed, 21 insertions(+), 1 deletion(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 6c03ff5..c365e7f 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -254,6 +254,21 @@ sub _resultset { > } > } > >+=head3 columns >+ >+my @columns = Koha::Objects->columns >+ >+Return the table columns >+ >+=cut >+ >+sub columns { >+ my ( $class ) = @_; >+ return Koha::Database->new->schema->resultset( $class->_type )->result_source->columns; >+} >+ >+ >+ > =head3 _type > > The _type method must be set for all child classes. >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 830db76..b92239a 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 => 1; >+use Test::More tests => 2; > > use Koha::Authority::Types; >+use Koha::Patrons; > use Koha::Database; > > use t::lib::TestBuilder; >@@ -31,5 +32,9 @@ $schema->storage->txn_begin; > > is( ref(Koha::Authority::Types->find('')), 'Koha::Authority::Type', 'Koha::Objects->find should work if the primary key is an empty string' ); > >+my @columns = Koha::Patrons->columns; >+my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns; >+is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' ); >+ > $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 16889
:
53240
|
53241
|
53243
|
53244
|
53292
|
53293
|
53294
|
53295
|
53379
| 53380 |
53381
|
53382
|
53383