Bugzilla – Attachment 95356 Details for
Bug 24030
GetItemsForInventory failing with "ORDER BY clause is not in SELECT list"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24030: Remove OldWay comparaison from GetItemsForInventory.t
Bug-24030-Remove-OldWay-comparaison-from-GetItemsF.patch (text/plain), 6.50 KB, created by
Jonathan Druart
on 2019-11-13 10:12:45 UTC
(
hide
)
Description:
Bug 24030: Remove OldWay comparaison from GetItemsForInventory.t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-11-13 10:12:45 UTC
Size:
6.50 KB
patch
obsolete
>From da3899abfd060319b28188638fee302846621660 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 13 Nov 2019 11:09:43 +0100 >Subject: [PATCH] Bug 24030: Remove OldWay comparaison from > GetItemsForInventory.t > >This has been introduced to make sure there were no regression at a >given point. But now we are fixing the "old way" so it does not make >sense to keep it any longer >--- > t/db_dependent/Items/GetItemsForInventory.t | 146 +--------------------------- > 1 file changed, 1 insertion(+), 145 deletions(-) > >diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t >index 56ca417e92..c54d8ae022 100755 >--- a/t/db_dependent/Items/GetItemsForInventory.t >+++ b/t/db_dependent/Items/GetItemsForInventory.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 7; > use t::lib::TestBuilder; > > use List::MoreUtils qw( any none ); >@@ -44,22 +44,6 @@ can_ok('C4::Items','GetItemsForInventory'); > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >-subtest 'Old version is unchanged' => sub { >- >- plan tests => 1; >- >- $schema->storage->txn_begin; >- >- my $dbh = $schema->storage->dbh; >- >- my ($oldResults, $oldCount) = OldWay($dbh); >- my ($newResults, $newCount) = GetItemsForInventory; >- >- is_deeply($newResults,$oldResults,"Inventory results unchanged."); >- >- $schema->storage->txn_rollback; >-}; >- > subtest 'Skip items with waiting holds' => sub { > > plan tests => 7; >@@ -137,16 +121,6 @@ subtest 'Skip items with waiting holds' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'Verify results with OldWay' => sub { >- $schema->storage->txn_begin; >- plan tests => 1; >- >- my ($oldResults, $oldCount) = OldWay(); >- my ($newResults, $newCount) = GetItemsForInventory(); >- is_deeply($newResults,$oldResults,"Inventory results unchanged."); >- $schema->storage->txn_rollback; >-}; >- > subtest 'Use cn_sort rather than callnumber to determine correct location' => sub { > $schema->storage->txn_begin; > plan tests => 1; >@@ -188,121 +162,3 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su > $schema->storage->txn_rollback; > > }; >- >-sub OldWay { # FIXME Do we really still need so much code to check results ?? >- my $ldbh = C4::Context->dbh; >- >- my $minlocation = ''; >- my $maxlocation = ''; >- my $location = ''; >- my $itemtype = ''; >- my $ignoreissued = ''; >- my $datelastseen = ''; >- my $branchcode = ''; >- my $branch = ''; >- my $offset = ''; >- my $size = ''; >- my $statushash = ''; >- >- my ( @bind_params, @where_strings ); >- >- my $select_columns = q{ >- SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, withdrawn, stocknumber >- }; >- my $select_count = q{SELECT COUNT(*)}; >- my $query = q{ >- FROM items >- LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber >- LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber >- }; >- if ($statushash){ >- for my $authvfield (keys %$statushash){ >- if ( scalar @{$statushash->{$authvfield}} > 0 ){ >- my $joinedvals = join ',', @{$statushash->{$authvfield}}; >- push @where_strings, "$authvfield in (" . $joinedvals . ")"; >- } >- } >- } >- >- if ($minlocation) { >- push @where_strings, 'itemcallnumber >= ?'; >- push @bind_params, $minlocation; >- } >- >- if ($maxlocation) { >- push @where_strings, 'itemcallnumber <= ?'; >- push @bind_params, $maxlocation; >- } >- >- if ($datelastseen) { >- $datelastseen = output_pref({ str => $datelastseen, dateformat => 'iso', dateonly => 1 }); >- push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)'; >- push @bind_params, $datelastseen; >- } >- >- if ( $location ) { >- push @where_strings, 'items.location = ?'; >- push @bind_params, $location; >- } >- >- if ( $branchcode ) { >- if($branch eq "homebranch"){ >- push @where_strings, 'items.homebranch = ?'; >- }else{ >- push @where_strings, 'items.holdingbranch = ?'; >- } >- push @bind_params, $branchcode; >- } >- >- if ( $itemtype ) { >- push @where_strings, 'biblioitems.itemtype = ?'; >- push @bind_params, $itemtype; >- } >- >- if ( $ignoreissued) { >- $query .= "LEFT JOIN issues ON items.itemnumber = issues.itemnumber "; >- push @where_strings, 'issues.date_due IS NULL'; >- } >- >- if ( @where_strings ) { >- $query .= 'WHERE '; >- $query .= join ' AND ', @where_strings; >- } >- my $count_query = $select_count . $query; >- $query .= ' ORDER BY items.cn_sort, itemcallnumber, title'; >- $query .= " LIMIT $offset, $size" if ($offset and $size); >- $query = $select_columns . $query; >- my $sth = $ldbh->prepare($query); >- $sth->execute( @bind_params ); >- >- my @results = (); >- my $tmpresults = $sth->fetchall_arrayref({}); >- $sth = $ldbh->prepare( $count_query ); >- $sth->execute( @bind_params ); >- my ($iTotalRecords) = $sth->fetchrow_array(); >- >- my $marc_field_mapping; >- foreach my $row (@$tmpresults) { >- >- # Auth values >- foreach my $field (sort keys %$row) { >- # If the koha field is mapped to a marc field >- my ($f, $sf) = C4::Biblio::GetMarcFromKohaField( "items.$field" ); >- if (defined($f) and defined($sf)) { >- # We replace the code with it's description >- my $avs; >- if ( exists $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf} ) { >- $avs = $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf}; >- } else { >- $avs = Koha::AuthorisedValues->search_by_marc_field({ frameworkcode => $row->{frameworkcode}, tagfield => $f, tagsubfield => $sf, }); >- $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf} = $avs->unblessed; >- } >- my $authvals = { map { $_->{authorised_value} => $_->{lib} } @{ $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf} } }; >- $row->{$field} = $authvals->{$row->{$field}} if defined $authvals && defined $row->{$field} && defined $authvals->{$row->{$field}}; >- } >- } >- push @results, $row; >- } >- >- return (\@results, $iTotalRecords); >-} >-- >2.11.0
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 24030
:
95356
|
95357
|
95377
|
95378