Skip to content

Commit a987499

Browse files
committed
fix: laravel 10.47 added query builder methods with same name (resolves #76)
1 parent 9a82c3a commit a987499

File tree

3 files changed

+53
-40
lines changed

3 files changed

+53
-40
lines changed

README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,21 +1027,24 @@ $query->where('invoice', 'like', 'RV-%')->orWhere('invoice', 'like', 'RZ-%');
10271027
$query->where('json', '??', 'key1')->where('json', '??', 'key2');
10281028

10291029
// you can do:
1030-
$query->whereAny('invoice', 'like', ['RV-%', 'RZ-%']);
1031-
$query->whereAll('json', '??', ['key1', 'key2']);
1030+
$query->whereAnyValue('invoice', 'like', ['RV-%', 'RZ-%']);
1031+
$query->whereAllValues('json', '??', ['key1', 'key2']);
10321032
```
10331033

10341034
```php
1035-
$query->whereAll($column, string $operator, iterable $values);
1036-
$query->whereNotAll($column, string $operator, iterable $values);
1037-
$query->orWhereAll($column, string $operator, iterable $values);
1038-
$query->orWhereNotAll($column, string $operator, iterable $values)
1039-
$query->whereAny($column, string $operator, iterable $values);
1040-
$query->whereNotAny($column, string $operator, iterable $values);
1041-
$query->orWhereAny($column, string $operator, iterable $values);
1042-
$query->orWhereNotAny($column, string $operator, iterable $values)
1035+
$query->whereAllValues($column, string $operator, iterable $values);
1036+
$query->whereNotAllValues($column, string $operator, iterable $values);
1037+
$query->orWhereAllValues($column, string $operator, iterable $values);
1038+
$query->orWhereNotAllValues($column, string $operator, iterable $values)
1039+
$query->whereAnyValue($column, string $operator, iterable $values);
1040+
$query->whereNotAnyValue($column, string $operator, iterable $values);
1041+
$query->orWhereAnyValue($column, string $operator, iterable $values);
1042+
$query->orWhereNotAnyValue($column, string $operator, iterable $values)
10431043
```
10441044

1045+
> [!CAUTION]
1046+
> The suffixes `Value` and `Values` had to be added to the method names since release 0.36.0 because the Laravel query builder also started to use these method names.
1047+
10451048
#### Boolean
10461049

10471050
As Laravel always casts boolean values to integers you will get a PostgreSQL errors like `operator does not exist: boolean = integer` sometimes.
@@ -1220,6 +1223,16 @@ class Example extends Model
12201223
12211224
# Breaking Changes
12221225

1226+
* 0.35.0 -> 0.36.0
1227+
* Some query builder methods had to be changed because they've now overlapped with new ones added by Laravel 10.47:
1228+
* `whereAll` -> `whereAllValues`
1229+
* `whereNotAll` -> `whereNotAllValues`
1230+
* `orWhereAll` -> `orWhereAllValues`
1231+
* `orWhereNotAll` -> `orWhereNotAllValues`
1232+
* `whereAny` -> `whereAnyValue`
1233+
* `whereNotAny` -> `whereNotAnyValue`
1234+
* `orWhereAny` -> `orWhereAnyValue`
1235+
* `orWhereNotAny` -> `orWhereNotAnyValue`
12231236
* 0.10.0 -> 0.11.0
12241237
* The `ZeroDowntimeMigration` concern namespace moved from `Tpetry\PostgresqlEnhanced\Concerns` to `Tpetry\PostgresqlEnhanced\Schema\Concerns`.
12251238
* 0.12.0 -> 0.12.1

src/Query/BuilderWhere.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ trait BuilderWhere
1313
*
1414
* @param Expression|string $column
1515
*/
16-
public function orWhereAll($column, string $operator, iterable $values): static
16+
public function orWhereAllValues($column, string $operator, iterable $values): static
1717
{
18-
return $this->whereAll($column, $operator, $values, boolean: 'or');
18+
return $this->whereAllValues($column, $operator, $values, boolean: 'or');
1919
}
2020

2121
/**
2222
* Add an or where any statement to the query.
2323
*
2424
* @param Expression|string $column
2525
*/
26-
public function orWhereAny($column, string $operator, iterable $values): static
26+
public function orWhereAnyValue($column, string $operator, iterable $values): static
2727
{
28-
return $this->whereAny($column, $operator, $values, boolean: 'or');
28+
return $this->whereAnyValue($column, $operator, $values, boolean: 'or');
2929
}
3030

3131
/**
@@ -74,19 +74,19 @@ public function orWhereLike($column, $value, bool $caseInsensitive = false): sta
7474
*
7575
* @param Expression|string $column
7676
*/
77-
public function orWhereNotAll($column, string $operator, iterable $values): static
77+
public function orWhereNotAllValues($column, string $operator, iterable $values): static
7878
{
79-
return $this->whereAll($column, $operator, $values, boolean: 'or', not: true);
79+
return $this->whereAllValues($column, $operator, $values, boolean: 'or', not: true);
8080
}
8181

8282
/**
8383
* Add an or where not any statement to the query.
8484
*
8585
* @param Expression|string $column
8686
*/
87-
public function orWhereNotAny($column, string $operator, iterable $values): static
87+
public function orWhereNotAnyValue($column, string $operator, iterable $values): static
8888
{
89-
return $this->whereAny($column, $operator, $values, boolean: 'or', not: true);
89+
return $this->whereAnyValue($column, $operator, $values, boolean: 'or', not: true);
9090
}
9191

9292
/**
@@ -115,7 +115,7 @@ public function orWhereNotBoolean($column, bool $value): static
115115
* @param Expression|string $column
116116
* @param 'and'|'or' $boolean
117117
*/
118-
public function whereAll($column, string $operator, iterable $values, string $boolean = 'and', bool $not = false): static
118+
public function whereAllValues($column, string $operator, iterable $values, string $boolean = 'and', bool $not = false): static
119119
{
120120
$type = 'all';
121121

@@ -131,7 +131,7 @@ public function whereAll($column, string $operator, iterable $values, string $bo
131131
* @param Expression|string $column
132132
* @param 'and'|'or' $boolean
133133
*/
134-
public function whereAny($column, string $operator, iterable $values, string $boolean = 'and', bool $not = false): static
134+
public function whereAnyValue($column, string $operator, iterable $values, string $boolean = 'and', bool $not = false): static
135135
{
136136
$type = 'any';
137137

@@ -198,19 +198,19 @@ public function whereLike($column, $value, bool $caseInsensitive = false, $boole
198198
*
199199
* @param Expression|string $column
200200
*/
201-
public function whereNotAll($column, string $operator, iterable $values): static
201+
public function whereNotAllValues($column, string $operator, iterable $values): static
202202
{
203-
return $this->whereAll($column, $operator, $values, not: true);
203+
return $this->whereAllValues($column, $operator, $values, not: true);
204204
}
205205

206206
/**
207207
* Add a where not any statement to the query.
208208
*
209209
* @param Expression|string $column
210210
*/
211-
public function whereNotAny($column, string $operator, iterable $values): static
211+
public function whereNotAnyValue($column, string $operator, iterable $values): static
212212
{
213-
return $this->whereAny($column, $operator, $values, not: true);
213+
return $this->whereAnyValue($column, $operator, $values, not: true);
214214
}
215215

216216
/**

tests/Query/WhereTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ protected function setUp(): void
1313
parent::setUp();
1414
}
1515

16-
public function testOrWhereAll(): void
16+
public function testOrWhereAllValues(): void
1717
{
1818
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
1919

2020
$queries = $this->withQueryLog(function (): void {
21-
$this->getConnection()->table('example')->orWhereAll('val', 'ilike', ['%test686120%', '%test787542%'])->orWhereAll('val', 'ilike', ['%test470781%', '%test236697%'])->get();
21+
$this->getConnection()->table('example')->orWhereAllValues('val', 'ilike', ['%test686120%', '%test787542%'])->orWhereAllValues('val', 'ilike', ['%test470781%', '%test236697%'])->get();
2222
});
2323
$this->assertEquals(
2424
['select * from "example" where "val" ilike all(array[?, ?]) or "val" ilike all(array[?, ?])'],
@@ -30,12 +30,12 @@ public function testOrWhereAll(): void
3030
);
3131
}
3232

33-
public function testOrWhereAny(): void
33+
public function testOrWhereAnyValue(): void
3434
{
3535
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
3636

3737
$queries = $this->withQueryLog(function (): void {
38-
$this->getConnection()->table('example')->orWhereAny('val', 'ilike', ['%test702465%', '%test825059%'])->orWhereAny('val', 'ilike', ['%test237377%', '%test592812%'])->get();
38+
$this->getConnection()->table('example')->orWhereAnyValue('val', 'ilike', ['%test702465%', '%test825059%'])->orWhereAnyValue('val', 'ilike', ['%test237377%', '%test592812%'])->get();
3939
});
4040
$this->assertEquals(
4141
['select * from "example" where "val" ilike any(array[?, ?]) or "val" ilike any(array[?, ?])'],
@@ -108,12 +108,12 @@ public function testOrWhereLike(): void
108108
);
109109
}
110110

111-
public function testOrWhereNotAll(): void
111+
public function testOrWhereNotAllValues(): void
112112
{
113113
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
114114

115115
$queries = $this->withQueryLog(function (): void {
116-
$this->getConnection()->table('example')->orWhereNotAll('val', 'ilike', ['leading793297%', '%trailing477609'])->orWhereNotAll('val', 'ilike', ['leading737659%', '%trailing474646'])->get();
116+
$this->getConnection()->table('example')->orWhereNotAllValues('val', 'ilike', ['leading793297%', '%trailing477609'])->orWhereNotAllValues('val', 'ilike', ['leading737659%', '%trailing474646'])->get();
117117
});
118118
$this->assertEquals(
119119
['select * from "example" where not "val" ilike all(array[?, ?]) or not "val" ilike all(array[?, ?])'],
@@ -125,12 +125,12 @@ public function testOrWhereNotAll(): void
125125
);
126126
}
127127

128-
public function testOrWhereNotAny(): void
128+
public function testOrWhereNotAnyValue(): void
129129
{
130130
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
131131

132132
$queries = $this->withQueryLog(function (): void {
133-
$this->getConnection()->table('example')->orWhereNotAny('val', 'ilike', ['%test475277%', '%test764076%'])->orWhereNotAny('val', 'ilike', ['%test936561%', '%test250628%'])->get();
133+
$this->getConnection()->table('example')->orWhereNotAnyValue('val', 'ilike', ['%test475277%', '%test764076%'])->orWhereNotAnyValue('val', 'ilike', ['%test936561%', '%test250628%'])->get();
134134
});
135135
$this->assertEquals(
136136
['select * from "example" where not "val" ilike any(array[?, ?]) or not "val" ilike any(array[?, ?])'],
@@ -172,12 +172,12 @@ public function testOrWhereNotBoolean(): void
172172
);
173173
}
174174

175-
public function testWhereAll(): void
175+
public function testWhereAllValues(): void
176176
{
177177
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
178178

179179
$queries = $this->withQueryLog(function (): void {
180-
$this->getConnection()->table('example')->whereAll('val', 'ilike', ['leading594111%', '%trailing359990'])->get();
180+
$this->getConnection()->table('example')->whereAllValues('val', 'ilike', ['leading594111%', '%trailing359990'])->get();
181181
});
182182
$this->assertEquals(
183183
['select * from "example" where "val" ilike all(array[?, ?])'],
@@ -189,12 +189,12 @@ public function testWhereAll(): void
189189
);
190190
}
191191

192-
public function testWhereAny(): void
192+
public function testWhereAnyValue(): void
193193
{
194194
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
195195

196196
$queries = $this->withQueryLog(function (): void {
197-
$this->getConnection()->table('example')->whereAny('val', 'ilike', ['%test157552%', '%test419109%'])->get();
197+
$this->getConnection()->table('example')->whereAnyValue('val', 'ilike', ['%test157552%', '%test419109%'])->get();
198198
});
199199
$this->assertEquals(
200200
['select * from "example" where "val" ilike any(array[?, ?])'],
@@ -267,12 +267,12 @@ public function testWhereLike(): void
267267
);
268268
}
269269

270-
public function testWhereNotAll(): void
270+
public function testWhereNotAllValues(): void
271271
{
272272
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
273273

274274
$queries = $this->withQueryLog(function (): void {
275-
$this->getConnection()->table('example')->whereNotAll('val', 'ilike', ['%test421400%', '%test763682%'])->get();
275+
$this->getConnection()->table('example')->whereNotAllValues('val', 'ilike', ['%test421400%', '%test763682%'])->get();
276276
});
277277
$this->assertEquals(
278278
['select * from "example" where not "val" ilike all(array[?, ?])'],
@@ -284,12 +284,12 @@ public function testWhereNotAll(): void
284284
);
285285
}
286286

287-
public function testWhereNotAny(): void
287+
public function testWhereNotAnyValue(): void
288288
{
289289
$this->getConnection()->unprepared('CREATE TABLE example (val text)');
290290

291291
$queries = $this->withQueryLog(function (): void {
292-
$this->getConnection()->table('example')->whereNotAny('val', 'ilike', ['%test299285%', '%test449782%'])->get();
292+
$this->getConnection()->table('example')->whereNotAnyValue('val', 'ilike', ['%test299285%', '%test449782%'])->get();
293293
});
294294
$this->assertEquals(
295295
['select * from "example" where not "val" ilike any(array[?, ?])'],

0 commit comments

Comments
 (0)