CRM-20970 - avoid MySQL error caused by long numeric postal codes
authormark burdett <mfburdett@gmail.com>
Wed, 26 Jul 2017 02:13:05 +0000 (19:13 -0700)
committermark burdett <mfburdett@gmail.com>
Wed, 26 Jul 2017 02:13:05 +0000 (19:13 -0700)
CRM/Contact/BAO/Query.php

index 2e4d34c0745219ebd5eb10e14db59bf41ade3b07..5d1eeff495975c9c672275c94b3007b056f3c1c4 100644 (file)
@@ -3625,7 +3625,7 @@ WHERE  $smartGroupClause
 
     // Handle numeric postal code range searches properly by casting the column as numeric
     if (is_numeric($value)) {
-      $field = "IF (civicrm_address.postal_code REGEXP '^[0-9]+$', CAST(civicrm_address.postal_code AS UNSIGNED), 0)";
+      $field = "IF (civicrm_address.postal_code REGEXP '^[0-9]{1,10}$', CAST(civicrm_address.postal_code AS UNSIGNED), 0)";
       $val = CRM_Utils_Type::escape($value, 'Integer');
     }
     else {