Bug 14778: Make Search.t pass - replace SHOW COLUMNS
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 26 Oct 2015 13:59:06 +0000 (13:59 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 26 Oct 2015 14:01:33 +0000 (11:01 -0300)
For an unkown reason, when executed from a test file, the 'SHOW COLUMNS'
statement does not return anything.
We need to retrieve the column list from the DBIx::Class resultset.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
C4/Search.pm

index e0f34bf..1a8bba0 100644 (file)
@@ -1889,10 +1889,9 @@ sub searchResults {
     my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber", "" );
 
     ## find column names of items related to MARC
-    my $sth2 = $dbh->prepare("SHOW COLUMNS FROM items");
-    $sth2->execute;
     my %subfieldstosearch;
-    while ( ( my $column ) = $sth2->fetchrow ) {
+    my @columns = Koha::Database->new()->schema()->resultset('Item')->result_source->columns;
+    for my $column ( @columns ) {
         my ( $tagfield, $tagsubfield ) =
           &GetMarcFromKohaField( "items." . $column, "" );
         if ( defined $tagsubfield ) {