|
4 | 4 |
|
5 | 5 | namespace Tpetry\PostgresqlEnhanced\Tests\Query;
|
6 | 6 |
|
| 7 | +use Illuminate\Support\Facades\App; |
7 | 8 | use Tpetry\PostgresqlEnhanced\Tests\TestCase;
|
8 | 9 |
|
9 | 10 | class WhereTest extends TestCase
|
@@ -98,28 +99,19 @@ public function testOrWhereLike(): void
|
98 | 99 | $this->getConnection()->table('example')->orWhereLike('str', 'ZsbBUJmR')->orWhereLike('str', '7Cc1Uf8t')->get();
|
99 | 100 | $this->getConnection()->table('example')->orWhereLike('str', 'OamekKIC', true)->orWhereLike('str', 'HmC3xURl', true)->get();
|
100 | 101 | });
|
101 |
| - $this->assertEquals( |
102 |
| - ['select * from "example" where "str" ilike ? or "str" ilike ?', 'select * from "example" where "str" like ? or "str" like ?'], |
103 |
| - array_column($queries, 'query'), |
104 |
| - ); |
105 |
| - $this->assertEquals( |
106 |
| - [['ZsbBUJmR', '7Cc1Uf8t'], ['OamekKIC', 'HmC3xURl']], |
107 |
| - array_column($queries, 'bindings'), |
108 |
| - ); |
109 |
| - } |
110 | 102 |
|
111 |
| - public function testOrWhereNotLike(): void |
112 |
| - { |
113 |
| - $this->getConnection()->unprepared('CREATE TABLE example (str text)'); |
| 103 | + if (version_compare(App::version(), '11.17.0', '>=')) { |
| 104 | + $this->assertEquals( |
| 105 | + ['select * from "example" where "str"::text ilike ? or "str"::text ilike ?', 'select * from "example" where "str"::text like ? or "str"::text like ?'], |
| 106 | + array_column($queries, 'query'), |
| 107 | + ); |
| 108 | + } else { |
| 109 | + $this->assertEquals( |
| 110 | + ['select * from "example" where "str" ilike ? or "str" ilike ?', 'select * from "example" where "str" like ? or "str" like ?'], |
| 111 | + array_column($queries, 'query'), |
| 112 | + ); |
| 113 | + } |
114 | 114 |
|
115 |
| - $queries = $this->withQueryLog(function (): void { |
116 |
| - $this->getConnection()->table('example')->orWhereNotLike('str', 'ZsbBUJmR')->orWhereNotLike('str', '7Cc1Uf8t')->get(); |
117 |
| - $this->getConnection()->table('example')->orWhereNotLike('str', 'OamekKIC', true)->orWhereNotLike('str', 'HmC3xURl', true)->get(); |
118 |
| - }); |
119 |
| - $this->assertEquals( |
120 |
| - ['select * from "example" where "str" not ilike ? or "str" not ilike ?', 'select * from "example" where "str" not like ? or "str" not like ?'], |
121 |
| - array_column($queries, 'query'), |
122 |
| - ); |
123 | 115 | $this->assertEquals(
|
124 | 116 | [['ZsbBUJmR', '7Cc1Uf8t'], ['OamekKIC', 'HmC3xURl']],
|
125 | 117 | array_column($queries, 'bindings'),
|
@@ -190,6 +182,33 @@ public function testOrWhereNotBoolean(): void
|
190 | 182 | );
|
191 | 183 | }
|
192 | 184 |
|
| 185 | + public function testOrWhereNotLike(): void |
| 186 | + { |
| 187 | + $this->getConnection()->unprepared('CREATE TABLE example (str text)'); |
| 188 | + |
| 189 | + $queries = $this->withQueryLog(function (): void { |
| 190 | + $this->getConnection()->table('example')->orWhereNotLike('str', 'ZsbBUJmR')->orWhereNotLike('str', '7Cc1Uf8t')->get(); |
| 191 | + $this->getConnection()->table('example')->orWhereNotLike('str', 'OamekKIC', true)->orWhereNotLike('str', 'HmC3xURl', true)->get(); |
| 192 | + }); |
| 193 | + |
| 194 | + if (version_compare(App::version(), '11.17.0', '>=')) { |
| 195 | + $this->assertEquals( |
| 196 | + ['select * from "example" where "str"::text not ilike ? or "str"::text not ilike ?', 'select * from "example" where "str"::text not like ? or "str"::text not like ?'], |
| 197 | + array_column($queries, 'query'), |
| 198 | + ); |
| 199 | + } else { |
| 200 | + $this->assertEquals( |
| 201 | + ['select * from "example" where "str" not ilike ? or "str" not ilike ?', 'select * from "example" where "str" not like ? or "str" not like ?'], |
| 202 | + array_column($queries, 'query'), |
| 203 | + ); |
| 204 | + } |
| 205 | + |
| 206 | + $this->assertEquals( |
| 207 | + [['ZsbBUJmR', '7Cc1Uf8t'], ['OamekKIC', 'HmC3xURl']], |
| 208 | + array_column($queries, 'bindings'), |
| 209 | + ); |
| 210 | + } |
| 211 | + |
193 | 212 | public function testWhereAllValues(): void
|
194 | 213 | {
|
195 | 214 | $this->getConnection()->unprepared('CREATE TABLE example (val text)');
|
@@ -275,28 +294,19 @@ public function testWhereLike(): void
|
275 | 294 | $this->getConnection()->table('example')->whereLike('str', 'UkAymQlg')->get();
|
276 | 295 | $this->getConnection()->table('example')->whereLike('str', 'IcuC5Cqz', true)->get();
|
277 | 296 | });
|
278 |
| - $this->assertEquals( |
279 |
| - ['select * from "example" where "str" ilike ?', 'select * from "example" where "str" like ?'], |
280 |
| - array_column($queries, 'query'), |
281 |
| - ); |
282 |
| - $this->assertEquals( |
283 |
| - [['UkAymQlg'], ['IcuC5Cqz']], |
284 |
| - array_column($queries, 'bindings'), |
285 |
| - ); |
286 |
| - } |
287 | 297 |
|
288 |
| - public function testWhereNotLike(): void |
289 |
| - { |
290 |
| - $this->getConnection()->unprepared('CREATE TABLE example (str text)'); |
| 298 | + if (version_compare(App::version(), '11.17.0', '>=')) { |
| 299 | + $this->assertEquals( |
| 300 | + ['select * from "example" where "str"::text ilike ?', 'select * from "example" where "str"::text like ?'], |
| 301 | + array_column($queries, 'query'), |
| 302 | + ); |
| 303 | + } else { |
| 304 | + $this->assertEquals( |
| 305 | + ['select * from "example" where "str" ilike ?', 'select * from "example" where "str" like ?'], |
| 306 | + array_column($queries, 'query'), |
| 307 | + ); |
| 308 | + } |
291 | 309 |
|
292 |
| - $queries = $this->withQueryLog(function (): void { |
293 |
| - $this->getConnection()->table('example')->whereNotLike('str', 'UkAymQlg')->get(); |
294 |
| - $this->getConnection()->table('example')->whereNotLike('str', 'IcuC5Cqz', true)->get(); |
295 |
| - }); |
296 |
| - $this->assertEquals( |
297 |
| - ['select * from "example" where "str" not ilike ?', 'select * from "example" where "str" not like ?'], |
298 |
| - array_column($queries, 'query'), |
299 |
| - ); |
300 | 310 | $this->assertEquals(
|
301 | 311 | [['UkAymQlg'], ['IcuC5Cqz']],
|
302 | 312 | array_column($queries, 'bindings'),
|
@@ -366,4 +376,31 @@ public function testWhereNotBoolean(): void
|
366 | 376 | array_column($queries, 'query'),
|
367 | 377 | );
|
368 | 378 | }
|
| 379 | + |
| 380 | + public function testWhereNotLike(): void |
| 381 | + { |
| 382 | + $this->getConnection()->unprepared('CREATE TABLE example (str text)'); |
| 383 | + |
| 384 | + $queries = $this->withQueryLog(function (): void { |
| 385 | + $this->getConnection()->table('example')->whereNotLike('str', 'UkAymQlg')->get(); |
| 386 | + $this->getConnection()->table('example')->whereNotLike('str', 'IcuC5Cqz', true)->get(); |
| 387 | + }); |
| 388 | + |
| 389 | + if (version_compare(App::version(), '11.17.0', '>=')) { |
| 390 | + $this->assertEquals( |
| 391 | + ['select * from "example" where "str"::text not ilike ?', 'select * from "example" where "str"::text not like ?'], |
| 392 | + array_column($queries, 'query'), |
| 393 | + ); |
| 394 | + } else { |
| 395 | + $this->assertEquals( |
| 396 | + ['select * from "example" where "str" not ilike ?', 'select * from "example" where "str" not like ?'], |
| 397 | + array_column($queries, 'query'), |
| 398 | + ); |
| 399 | + } |
| 400 | + |
| 401 | + $this->assertEquals( |
| 402 | + [['UkAymQlg'], ['IcuC5Cqz']], |
| 403 | + array_column($queries, 'bindings'), |
| 404 | + ); |
| 405 | + } |
369 | 406 | }
|
0 commit comments