Bug 8533 - Non-numeric cardnumbers screw up autoMemberNum
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 31 Jul 2012 12:14:19 +0000 (08:14 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 31 Aug 2012 16:23:43 +0000 (18:23 +0200)
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Removes a warning from mysql:
    Truncated incorrect INTEGER value: 'P13000'

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Members.pm

index 2e59c91..2e315aa 100644 (file)
@@ -899,11 +899,8 @@ sub fixup_cardnumber {
         return "V$cardnumber$rem";
      } else {
 
-     # MODIFIED BY JF: mysql4.1 allows casting as an integer, which is probably
-     # better. I'll leave the original in in case it needs to be changed for you
-     # my $sth=$dbh->prepare("select max(borrowers.cardnumber) from borrowers");
         my $sth = $dbh->prepare(
-            "select max(cast(cardnumber as signed)) from borrowers"
+            'SELECT MAX( CAST( cardnumber AS SIGNED ) ) FROM borrowers WHERE cardnumber REGEXP "^-?[0-9]+$"'
         );
         $sth->execute;
         my ($result) = $sth->fetchrow;