Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Commit

Permalink
Added NOT BETWEEN operator
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrogehlen committed May 25, 2021
2 parents 3e36e24 + e3a96c4 commit f50ab91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function init()
'greater' => '> ?',
'greater_or_equal' => '>= ?',
'between' => ['op' => 'BETWEEN ?', 'list' => true, 'sep' => ' AND '],
'not_between' => ['op' => 'NOT BETWEEN ?', 'list' => true, 'sep' => ' AND '],
'begins_with' => ['op' => 'LIKE ?', 'fn' => function($value){ return "$value%"; } ],
'not_begins_with' => ['op' => 'NOT LIKE ?', 'fn' => function($value){ return "$value%"; } ],
'contains' => ['op' => 'LIKE ?', 'fn' => function($value){ return "%$value%"; } ],
Expand Down Expand Up @@ -168,4 +169,4 @@ public function params()
{
return $this->_params;
}
}
}
8 changes: 7 additions & 1 deletion tests/unit/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ protected function rulesProvider()
]],
['(date BETWEEN :p0 AND :p1)', [':p0'=>'2015-01-01', ':p1'=>'2015-01-30']]
],
[
['condition' => "and", 'rules' => [
[ 'field' => 'date', 'type' => 'date', 'operator' => 'not_between', 'value' => ['2015-01-01','2015-01-30']],
]],
['(date NOT BETWEEN :p0 AND :p1)', [':p0'=>'2015-01-01', ':p1'=>'2015-01-30']]
],
[
['condition' => "and", 'rules' => [
[ 'field' => 'name', 'type' => 'string', 'operator' => 'begins_with', 'value' => 'joe'],
Expand Down Expand Up @@ -111,4 +117,4 @@ public function testRules()
}
}
}
}
}

0 comments on commit f50ab91

Please sign in to comment.