Skip to content

Commit

Permalink
Merge pull request #12991 from eileenmcnaughton/strtolower_city
Browse files Browse the repository at this point in the history
Remove use of LOWER from city & street searches
  • Loading branch information
seamuslee001 authored Oct 29, 2018
2 parents 83b778b + 54e02ce commit 72e9f2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2294,8 +2294,7 @@ public function restWhere(&$values) {

//get the location name
list($tName, $fldName) = self::getLocationTableName($field['where'], $locType);
// LOWER roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
$fieldName = "LOWER(`$tName`.$fldName)";
$fieldName = "`$tName`.$fldName";

// we set both _tables & whereTables because whereTables doesn't seem to do what the name implies it should
$this->_tables[$tName] = $this->_whereTables[$tName] = 1;
Expand All @@ -2307,8 +2306,7 @@ public function restWhere(&$values) {
}
else {
if ($op != 'IN' && !is_numeric($value) && !is_array($value)) {
// LOWER roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
$fieldName = "LOWER({$field['where']})";
$fieldName = "{$field['where']}";
}
else {
$fieldName = "{$field['where']}";
Expand Down Expand Up @@ -3566,7 +3564,6 @@ public function street_address(&$values) {
$value = "%{$value}%";
}
$op = 'LIKE';
// LOWER roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
$this->_where[$grouping][] = self::buildClause('civicrm_address.street_address', $op, $value, 'String');
$this->_qill[$grouping][] = ts('Street') . " $op '$n'";
}
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Contact/BAO/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ public function testSearchProfilePrimaryCityCRM14263($params, $selectClause, $wh
CRM_Core_Config::singleton()->defaultSearchProfileID = 1;
$this->callAPISuccess('address', 'create', array(
'contact_id' => $contactID,
'city' => 'Cool City',
'street_address' => 'Long Street',
'city' => 'Cool CITY',
'street_address' => 'Long STREET',
'location_type_id' => 1,
));
$returnProperties = array(
Expand Down Expand Up @@ -257,7 +257,7 @@ public function testSearchProfilePrimaryCityCRM14263($params, $selectClause, $wh
public function getSearchProfileData() {
return [
[
[['city', '=', 'Cool City', 1, 0]], "civicrm_address.city as `city`", "LOWER(civicrm_address.city) = 'cool city'",
[['city', '=', 'Cool City', 1, 0]], "civicrm_address.city as `city`", "civicrm_address.city = 'cool city'",
],
[
// Note that in the query 'long street' is lower cased. We eventually want to change that & not mess with the vars - it turns out
Expand Down

0 comments on commit 72e9f2d

Please sign in to comment.