From 2667b93f26726997b7f983b2ee100b8fad036c71 Mon Sep 17 00:00:00 2001 From: Andrew Fuerste-Henry Date: Wed, 29 Jul 2020 19:13:22 +0000 Subject: [PATCH] Bug 26035: AutoMemberNum should support cardnumbers up to 32 characters To test: 1- create a patron with cardnumber 12345678901234567890123456789012 (or any 32 character number) 2- turn on AutoMemberNum 3- create a new patron, save without a cardnumber 4- confirm that new patron has a cardnumber one more than the number from step 1 --- Koha/Patron.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 5436ccc448..65692c7651 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -24,6 +24,7 @@ use Carp; use List::MoreUtils qw( any uniq ); use JSON qw( to_json ); use Unicode::Normalize; +use bigint; use C4::Context; use C4::Log; @@ -113,10 +114,10 @@ sub fixup_cardnumber { my $max = Koha::Patrons->search({ cardnumber => {-regexp => '^-?[0-9]+$'} }, { - select => \'CAST(cardnumber AS SIGNED)', - as => ['cast_cardnumber'] - })->_resultset->get_column('cast_cardnumber')->max; - $self->cardnumber(($max || 0) +1); + order_by => \'(cardnumber+0) DESC', + })->next; + return unless $max; + $self->cardnumber(($max->cardnumber || 0) +1); } =head3 trim_whitespace -- 2.11.0