From abc78dd48315dfb5684af52a47182bd894313e0e Mon Sep 17 00:00:00 2001 From: mark burdett Date: Tue, 25 Jul 2017 19:13:05 -0700 Subject: [PATCH] CRM-20970 - avoid MySQL error caused by long numeric postal codes --- CRM/Contact/BAO/Query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 2e4d34c07452..5d1eeff49597 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3625,7 +3625,7 @@ public function postalCode(&$values) { // 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 {