From cce230033bdff8003526f152570ec4d4037d41fc Mon Sep 17 00:00:00 2001 From: Eileen Date: Wed, 21 May 2014 05:07:52 -0400 Subject: [PATCH] CRM-14720 - smart groups based on postal code numeric ranges cause fatal --- 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 6f1798ac6fb3..d4084186e177 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3586,7 +3586,7 @@ public function postalCode(&$values) { // Handle numeric postal code range searches properly by casting the column as numeric if (is_numeric($value)) { - $field = 'ROUND(civicrm_address.postal_code)'; + $field = "IF (civicrm_address.postal_code REGEXP '^[0-9]+$', CAST(civicrm_address.postal_code AS UNSIGNED), 0)"; $val = CRM_Utils_Type::escape($value, 'Integer'); } else {