From 2d326177ae9faa6007ea835b1b793c7ec49168df Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Mar 2017 18:58:55 -0300 Subject: [PATCH] Bug 18093: Koha::Objects->get_column should not return a DBIC object Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- Koha/Objects.pm | 13 ++++++++++++- t/db_dependent/Koha/Objects.t | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 7d0ae81ff7..7e73297695 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -276,6 +276,17 @@ sub unblessed { return [ map { $_->unblessed } $self->as_list ]; } +=head3 Koha::Objects->get_column + +Return all the values of this set for a given column + +=cut + +sub get_column { + my ($self, $column_name) = @_; + return $self->_resultset->get_column( $column_name )->all; +} + =head3 Koha::Objects->TO_JSON Returns an unblessed representation of objects, suitable for JSON output. @@ -359,7 +370,7 @@ Currently count, pager, update and delete are covered. sub AUTOLOAD { my ( $self, @params ) = @_; - my @known_methods = qw( count pager update delete result_class single slice get_column ); + my @known_methods = qw( count pager update delete result_class single slice ); my $method = our $AUTOLOAD; $method =~ s/.*:://; diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index 44fda50a5b..935dc47bec 100644 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -144,7 +144,7 @@ subtest 'get_column' => sub { plan tests => 1; my @cities = Koha::Cities->search; my @city_names = map { $_->city_name } @cities; - is_deeply( [ Koha::Cities->search->get_column('city_name')->all ], \@city_names, 'Koha::Objects->get_column should be allowed' ); + is_deeply( [ Koha::Cities->search->get_column('city_name') ], \@city_names, 'Koha::Objects->get_column should be allowed' ); }; subtest 'Exceptions' => sub { -- 2.39.5