Skip to content

Commit ebaeadd

Browse files
committed
whereFieldDoesntExist to whereNotFieldExists
1 parent 323a7be commit ebaeadd

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ This release is compatible with Laravel 11, 12 & 13
88

99
### Added
1010

11-
- **`whereNestedFieldExists($path)`** ([docs](https://elasticsearch.pdphilip.com/eloquent/nested-queries#where-nested-field-exists)) - explicit, zero-overhead check for "this nested path has at least one document." Emits the idiomatic `nested + exists` form directly, no closure required. Variants: `whereNestedFieldDoesntExist`, `orWhereNestedFieldExists`, `orWhereNestedFieldDoesntExist`.
12-
- **`whereFieldExists($field)`** ([docs](https://elasticsearch.pdphilip.com/eloquent/eloquent-queries#wherefieldexists)) - properly named alias for the Elasticsearch `exists` query. Variants: `whereFieldDoesntExist`, `orWhereFieldExists`, `orWhereFieldDoesntExist`.
11+
- **`whereNestedFieldExists($path)`** ([docs](https://elasticsearch.pdphilip.com/eloquent/nested-queries#where-nested-field-exists)) - explicit, zero-overhead check for "this nested path has at least one document." Emits the idiomatic `nested + exists` form directly, no closure required. Variants: `whereNotNestedFieldExists`, `orWhereNestedFieldExists`, `orWhereNotNestedFieldExists`.
12+
- **`whereFieldExists($field)`** ([docs](https://elasticsearch.pdphilip.com/eloquent/eloquent-queries#wherefieldexists)) - properly named alias for the Elasticsearch `exists` query. Variants: `whereNotFieldExists`, `orWhereFieldExists`, `orWhereNotFieldExists`.
1313
- **`nestedQuery($column)`** ([docs](https://elasticsearch.pdphilip.com/eloquent/nested-queries#building-the-inner-query-programmatically)) - returns a pre-configured Builder you can build up across conditionals and functions, then pass straight to `whereNestedObject()`. The closure form still works for simple cases; this is the escape hatch for programmatic composition.
1414
- `whereNestedObject()` now accepts a pre-built Builder (from `nestedQuery()`) in addition to a Closure or raw DSL string. Invalid input now throws `BuilderException` instead of silently being stored.
1515

@@ -22,9 +22,9 @@ This release is compatible with Laravel 11, 12 & 13
2222

2323
- **`whereTermExists` family** - replaced by `whereFieldExists`. The `Term` prefix was historical (the underlying ES query isn't term-related) and the old name avoided collision with Laravel's base `whereExists(Closure)`. Old methods still work; will be removed in v6:
2424
- `whereTermExists``whereFieldExists`
25-
- `whereNotTermExists``whereFieldDoesntExist`
25+
- `whereNotTermExists``whereNotFieldExists`
2626
- `orWhereTermExists``orWhereFieldExists`
27-
- `orWhereNotTermsExists``orWhereFieldDoesntExist` (also fixes the typo'd plural "Terms")
27+
- `orWhereNotTermsExists``orWhereNotFieldExists` (also fixes the typo'd plural "Terms")
2828

2929
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.6.1...v5.7.0
3030

src/Eloquent/Docs/ModelDocs.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@
8282
* @method static $this orWhereNestedObject($column, $query, $filterInnerHits = false, $options = [])
8383
* @method static $this orWhereNotNestedObject($column, $query, $filterInnerHits = false, $options = [])
8484
* @method static $this whereNestedFieldExists(string $path, string $boolean = 'and', bool $not = false)
85-
* @method static $this whereNestedFieldDoesntExist(string $path)
85+
* @method static $this whereNotNestedFieldExists(string $path)
8686
* @method static $this orWhereNestedFieldExists(string $path)
87-
* @method static $this orWhereNestedFieldDoesntExist(string $path)
87+
* @method static $this orWhereNotNestedFieldExists(string $path)
8888
*-----------------------------------
8989
* @method static $this whereFieldExists($column, $boolean = 'and', $not = false)
90-
* @method static $this whereFieldDoesntExist($column)
90+
* @method static $this whereNotFieldExists($column)
9191
* @method static $this orWhereFieldExists($column)
92-
* @method static $this orWhereFieldDoesntExist($column)
92+
* @method static $this orWhereNotFieldExists($column)
9393
* @method static $this whereTermExists($column, $boolean = 'and', $not = false) @deprecated use whereFieldExists
94-
* @method static $this whereNotTermExists($column) @deprecated use whereFieldDoesntExist
94+
* @method static $this whereNotTermExists($column) @deprecated use whereNotFieldExists
9595
* @method static $this orWhereTermExists($column) @deprecated use orWhereFieldExists
96-
* @method static $this orWhereNotTermsExists($column) @deprecated use orWhereFieldDoesntExist
96+
* @method static $this orWhereNotTermsExists($column) @deprecated use orWhereNotFieldExists
9797
*-----------------------------------
9898
* @method static $this whereRaw($dsl, $bindings = [], $boolean = 'and', $options = [])
9999
*===========================================

src/Query/Concerns/BuildsFieldQueries.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function whereFieldExists($column, $boolean = 'and', $not = false): self
107107
return $this;
108108
}
109109

110-
public function whereFieldDoesntExist($column): self
110+
public function whereNotFieldExists($column): self
111111
{
112112
return $this->whereFieldExists($column, 'and', true);
113113
}
@@ -117,7 +117,7 @@ public function orWhereFieldExists($column): self
117117
return $this->whereFieldExists($column, 'or', false);
118118
}
119119

120-
public function orWhereFieldDoesntExist($column): self
120+
public function orWhereNotFieldExists($column): self
121121
{
122122
return $this->whereFieldExists($column, 'or', true);
123123
}
@@ -131,7 +131,7 @@ public function whereTermExists($column, $boolean = 'and', $not = false): self
131131
}
132132

133133
/**
134-
* @deprecated Use whereFieldDoesntExist() instead. Will be removed in v6.
134+
* @deprecated Use whereNotFieldExists() instead. Will be removed in v6.
135135
*/
136136
public function whereNotTermExists($column): self
137137
{
@@ -147,7 +147,7 @@ public function orWhereTermExists($column): self
147147
}
148148

149149
/**
150-
* @deprecated Use orWhereFieldDoesntExist() instead. Will be removed in v6.
150+
* @deprecated Use orWhereNotFieldExists() instead. Will be removed in v6.
151151
* Note: the original method name had a typo ("Terms" plural).
152152
*/
153153
public function orWhereNotTermsExists($column): self

src/Query/Concerns/BuildsNestedQueries.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function whereNestedFieldExists(string $path, string $boolean = 'and', bo
152152
return $this;
153153
}
154154

155-
public function whereNestedFieldDoesntExist(string $path): self
155+
public function whereNotNestedFieldExists(string $path): self
156156
{
157157
return $this->whereNestedFieldExists($path, 'and', true);
158158
}
@@ -162,7 +162,7 @@ public function orWhereNestedFieldExists(string $path): self
162162
return $this->whereNestedFieldExists($path, 'or', false);
163163
}
164164

165-
public function orWhereNestedFieldDoesntExist(string $path): self
165+
public function orWhereNotNestedFieldExists(string $path): self
166166
{
167167
return $this->whereNestedFieldExists($path, 'or', true);
168168
}

tests/QueryElasticsearchSpecificTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@
197197
expect(User::whereFieldExists('title')->count())->toBe(8);
198198
});
199199

200-
it('whereFieldDoesntExist matches users with the field missing', function () {
201-
expect(User::whereFieldDoesntExist('title')->count())->toBe(1);
200+
it('whereNotFieldExists matches users with the field missing', function () {
201+
expect(User::whereNotFieldExists('title')->count())->toBe(1);
202202
});
203203

204204
it('whereFieldExists is parity with deprecated whereTermExists', function () {
@@ -266,8 +266,8 @@
266266
expect(Post::whereNestedFieldExists('comments')->count())->toBe(4);
267267
});
268268

269-
it('whereNestedFieldDoesntExist wraps nested inside must_not', function () {
270-
$dsl = Post::whereNestedFieldDoesntExist('comments')->toDsl();
269+
it('whereNotNestedFieldExists wraps nested inside must_not', function () {
270+
$dsl = Post::whereNotNestedFieldExists('comments')->toDsl();
271271

272272
$mustNot = $dsl['body']['query']['bool']['must_not'][0];
273273
expect($mustNot)->toHaveKey('nested')

0 commit comments

Comments
 (0)