Skip to content

Commit b7197cd

Browse files
committed
Update query string methods and tests for flexibility
Changed default $fields parameter in query string methods from '*' to null for greater flexibility. Added a new test to verify combining query string searches with standard query operators. Also fixed duplicate 'fuzzy_transpositions' entry and added 'fuzzyRewrite' method annotation in QueryStringOptions.
1 parent 295ac8a commit b7197cd

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/Eloquent/Docs/ModelDocs.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@
128128
* @method static $this searchNotFuzzyPrefix($term, $fields = ['*'], $options = [])
129129
* @method static $this orSearchNotFuzzyPrefix($term, $fields = ['*'], $options = [])
130130
* -----------------------------------
131-
* @method static $this searchQueryString($query, $fields = '*', $options = [])
132-
* @method static $this orSearchQueryString($query, $fields = '*', $options = [])
133-
* @method static $this searchNotQueryString($query, $fields = '*', $options = [])
134-
* @method static $this orSearchNotQueryString($query, $fields = '*', $options = [])
131+
* @method static $this searchQueryString($query, $fields = null, $options = [])
132+
* @method static $this orSearchQueryString($query, $fields = null, $options = [])
133+
* @method static $this searchNotQueryString($query, $fields = null, $options = [])
134+
* @method static $this orSearchNotQueryString($query, $fields = null, $options = [])
135135
*===========================================
136136
* Speciality methods
137137
*===========================================

src/Query/Options/QueryStringOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* @method $this fuzzyMaxExpansions(int $value)
1818
* @method $this fuzzyPrefixLength(int $value)
1919
* @method $this fuzzyTranspositions(bool $value)
20+
* @method $this fuzzyRewrite(int $value)
2021
* @method $this lenient(bool $value)
2122
* @method $this maxDeterminizedStates(int $value)
2223
* @method $this minimumShouldMatch(string $value)
@@ -43,7 +44,6 @@ public function allowedOptions(): array
4344
'fuzzy_prefix_length',
4445
'fuzzy_transpositions',
4546
'fuzzy_rewrite',
46-
'fuzzy_transpositions',
4747
'lenient',
4848
'max_determinized_states',
4949
'minimum_should_match',

tests/QueryStringTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@
5858

5959
});
6060

61+
it('tests basic query string combined with normal query operators', function () {
62+
$users = User::searchQueryString('age:35')->where('title', 'admin')->get();
63+
expect($users)->toHaveCount(2);
64+
65+
$users = User::searchQueryString('age:>30')->count();
66+
expect($users)->toBe(6);
67+
68+
$users = User::searchQueryString('age:(NOT 35)')->skip(4)->limit(3)->get();
69+
expect($users)->toHaveCount(2);
70+
71+
});
72+
6173
it('tests AND query string', function () {
6274

6375
$users = User::searchQueryString('age:35')->searchQueryString('title:admin')->get();

0 commit comments

Comments
 (0)