--- a/Koha/Objects.pm +++ a/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. --- a/t/db_dependent/Koha/Objects.t +++ a/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; --