Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REF Ensure that when doing RLIKE BINARY the field is cast as BINARY t… #19399

Merged
merged 1 commit into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -5628,7 +5628,7 @@ public static function buildClause($field, $op, $value = NULL, $dataType = NULL)
return $clause;

case 'RLIKE':
return " {$clause} BINARY '{$value}' ";
return " CAST({$field} AS BINARY) RLIKE BINARY '{$value}' ";

case 'IN':
case 'NOT IN':
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contact/SelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public function testWhereClauseByOperator() {
// case insensitive check
'LIKE' => "( contact_a.first_name LIKE '%Ad%' )",
// case sensitive check
'RLIKE' => "( contact_a.first_name RLIKE BINARY '^A[a-z]{3}$' )",
'RLIKE' => "( CAST(contact_a.first_name AS BINARY) RLIKE BINARY '^A[a-z]{3}$' )",
// case sensitive check
'IN' => '( contact_a.first_name IN ("Adam") )',
];
Expand Down