Skip to content

Commit 30510ec

Browse files
committed
fix filtering with operator not like issue
1 parent 22996c2 commit 30510ec

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -978,9 +978,13 @@ protected function compileWhereBasic(array $where)
978978
{
979979
extract($where);
980980

981-
// Replace like with a Regex instance.
982-
if ($operator == 'like') {
983-
$operator = '=';
981+
// Replace like or not like with a Regex instance.
982+
if (in_array($operator, ['like', 'not like'])) {
983+
if (Str::startsWith($operator, 'not')) {
984+
$operator = 'not';
985+
} else {
986+
$operator = '=';
987+
}
984988

985989
// Convert to regular expression.
986990
$regex = preg_replace('#(^|[^\\\])%#', '$1.*', preg_quote($value));

0 commit comments

Comments
 (0)