@@ -305,20 +305,25 @@ public function testWheresWithArrayValue()
305
305
$ this ->assertSame ('select * from "users" where "id" = ? ' , $ builder ->toSql ());
306
306
$ this ->assertEquals ([0 => 12 ], $ builder ->getBindings ());
307
307
308
- // $builder = $this->getBuilder();
309
- // $builder->select('*')->from('users')->where('id', '=', [12, 30]);
310
- // $this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
311
- // $this->assertEquals([0 => 12, 1 => 30 ], $builder->getBindings());
308
+ $ builder = $ this ->getBuilder ();
309
+ $ builder ->select ('* ' )->from ('users ' )->where ('id ' , '= ' , [12 , 30 ]);
310
+ $ this ->assertSame ('select * from "users" where "id" = ? ' , $ builder ->toSql ());
311
+ $ this ->assertEquals ([0 => 12 ], $ builder ->getBindings ());
312
312
313
- // $builder = $this->getBuilder();
314
- // $builder->select('*')->from('users')->where('id', '!=', [12, 30]);
315
- // $this->assertSame('select * from "users" where "id" != ?', $builder->toSql());
316
- // $this->assertEquals([0 => 12, 1 => 30 ], $builder->getBindings());
313
+ $ builder = $ this ->getBuilder ();
314
+ $ builder ->select ('* ' )->from ('users ' )->where ('id ' , '!= ' , [12 , 30 ]);
315
+ $ this ->assertSame ('select * from "users" where "id" != ? ' , $ builder ->toSql ());
316
+ $ this ->assertEquals ([0 => 12 ], $ builder ->getBindings ());
317
317
318
- // $builder = $this->getBuilder();
319
- // $builder->select('*')->from('users')->where('id', '<>', [12, 30]);
320
- // $this->assertSame('select * from "users" where "id" <> ?', $builder->toSql());
321
- // $this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
318
+ $ builder = $ this ->getBuilder ();
319
+ $ builder ->select ('* ' )->from ('users ' )->where ('id ' , '<> ' , [12 , 30 ]);
320
+ $ this ->assertSame ('select * from "users" where "id" <> ? ' , $ builder ->toSql ());
321
+ $ this ->assertEquals ([0 => 12 ], $ builder ->getBindings ());
322
+
323
+ $ builder = $ this ->getBuilder ();
324
+ $ builder ->select ('* ' )->from ('users ' )->where ('id ' , '= ' , [[12 , 30 ]]);
325
+ $ this ->assertSame ('select * from "users" where "id" = ? ' , $ builder ->toSql ());
326
+ $ this ->assertEquals ([0 => 12 ], $ builder ->getBindings ());
322
327
}
323
328
324
329
public function testMySqlWrappingProtectsQuotationMarks ()
@@ -649,6 +654,16 @@ public function testWhereBetweens()
649
654
$ this ->assertSame ('select * from "users" where "id" between ? and ? ' , $ builder ->toSql ());
650
655
$ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
651
656
657
+ $ builder = $ this ->getBuilder ();
658
+ $ builder ->select ('* ' )->from ('users ' )->whereBetween ('id ' , [[1 , 2 , 3 ]]);
659
+ $ this ->assertSame ('select * from "users" where "id" between ? and ? ' , $ builder ->toSql ());
660
+ $ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
661
+
662
+ $ builder = $ this ->getBuilder ();
663
+ $ builder ->select ('* ' )->from ('users ' )->whereBetween ('id ' , [[1 ], [2 , 3 ]]);
664
+ $ this ->assertSame ('select * from "users" where "id" between ? and ? ' , $ builder ->toSql ());
665
+ $ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
666
+
652
667
$ builder = $ this ->getBuilder ();
653
668
$ builder ->select ('* ' )->from ('users ' )->whereNotBetween ('id ' , [1 , 2 ]);
654
669
$ this ->assertSame ('select * from "users" where "id" not between ? and ? ' , $ builder ->toSql ());
@@ -1244,10 +1259,19 @@ public function testHavings()
1244
1259
$ builder = $ this ->getBuilder ();
1245
1260
$ builder ->select (['category ' , new Raw ('count(*) as "total" ' )])->from ('item ' )->where ('department ' , '= ' , 'popular ' )->groupBy ('category ' )->having ('total ' , '> ' , 3 );
1246
1261
$ this ->assertSame ('select "category", count(*) as "total" from "item" where "department" = ? group by "category" having "total" > ? ' , $ builder ->toSql ());
1262
+ }
1263
+
1264
+ public function testHavingBetweens ()
1265
+ {
1266
+ $ builder = $ this ->getBuilder ();
1267
+ $ builder ->select ('* ' )->from ('users ' )->havingBetween ('id ' , [1 , 2 , 3 ]);
1268
+ $ this ->assertSame ('select * from "users" having "id" between ? and ? ' , $ builder ->toSql ());
1269
+ $ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
1247
1270
1248
1271
$ builder = $ this ->getBuilder ();
1249
- $ builder ->select ('* ' )->from ('users ' )->havingBetween ('last_login_date ' , ['2018-11-16 ' , '2018-12-16 ' ]);
1250
- $ this ->assertSame ('select * from "users" having "last_login_date" between ? and ? ' , $ builder ->toSql ());
1272
+ $ builder ->select ('* ' )->from ('users ' )->havingBetween ('id ' , [[1 , 2 ], [3 , 4 ]]);
1273
+ $ this ->assertSame ('select * from "users" having "id" between ? and ? ' , $ builder ->toSql ());
1274
+ $ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
1251
1275
}
1252
1276
1253
1277
public function testHavingShortcut ()
0 commit comments