From befbae84691bd496eb78aa806fbdcc57e4f03ff6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 24 Feb 2016 17:10:02 +0000 Subject: [PATCH] Bug 15877 - C4::Barcodes does not correctly calculate db_max for 'annual' barcodes This patch alters the MySQL query to remove a max statement which incorrectly groups full annual barcodes with numeric values. Signed-off-by: Srdjan Signed-off-by: Jonathan Druart Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com (cherry picked from commit a3557fd0f25371246445ff2e327eaa5df5bf6e8f) Signed-off-by: Julian Maurice --- C4/Barcodes/annual.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Barcodes/annual.pm b/C4/Barcodes/annual.pm index c2e8d0ba8c..74346ddd23 100644 --- a/C4/Barcodes/annual.pm +++ b/C4/Barcodes/annual.pm @@ -39,8 +39,8 @@ BEGIN { sub db_max ($;$) { my $self = shift; - my $query = "SELECT max(substring_index(barcode,'-',-1)) AS chunk,barcode FROM items WHERE barcode LIKE ? GROUP BY barcode"; - # FIXME: unreasonably expensive query on large datasets + my $query = "SELECT substring_index(barcode,'-',-1) AS chunk,barcode FROM items WHERE barcode LIKE ? ORDER BY chunk DESC LIMIT 1"; + # FIXME: unreasonably expensive query on large datasets (I think removal of group by does this?) my $sth = C4::Context->dbh->prepare($query); my ($iso); if (@_) { -- 2.39.5