@@ -166,6 +166,16 @@ class QueryBuilderTest extends DatabaseTestCase
[['or like','name',['heyho','abc']],'`name` LIKE :qp0 OR `name` LIKE :qp1',[':qp0'=>'%heyho%',':qp1'=>'%abc%']],
[['or not like','name',['heyho','abc']],'`name` NOT LIKE :qp0 OR `name` NOT LIKE :qp1',[':qp0'=>'%heyho%',':qp1'=>'%abc%']],
// like with Expression
[['like','name',newExpression('CONCAT("test", colname, "%")')],'`name` LIKE CONCAT("test", colname, "%")',[]],
[['not like','name',newExpression('CONCAT("test", colname, "%")')],'`name` NOT LIKE CONCAT("test", colname, "%")',[]],
[['or like','name',newExpression('CONCAT("test", colname, "%")')],'`name` LIKE CONCAT("test", colname, "%")',[]],
[['or not like','name',newExpression('CONCAT("test", colname, "%")')],'`name` NOT LIKE CONCAT("test", colname, "%")',[]],
[['like','name',[newExpression('CONCAT("test", colname, "%")'),'abc']],'`name` LIKE CONCAT("test", colname, "%") AND `name` LIKE :qp0',[':qp0'=>'%abc%']],
[['not like','name',[newExpression('CONCAT("test", colname, "%")'),'abc']],'`name` NOT LIKE CONCAT("test", colname, "%") AND `name` NOT LIKE :qp0',[':qp0'=>'%abc%']],
[['or like','name',[newExpression('CONCAT("test", colname, "%")'),'abc']],'`name` LIKE CONCAT("test", colname, "%") OR `name` LIKE :qp0',[':qp0'=>'%abc%']],
[['or not like','name',[newExpression('CONCAT("test", colname, "%")'),'abc']],'`name` NOT LIKE CONCAT("test", colname, "%") OR `name` NOT LIKE :qp0',[':qp0'=>'%abc%']],
// not
[['not','name'],'NOT (name)',[]],
...
...
@@ -177,10 +187,13 @@ class QueryBuilderTest extends DatabaseTestCase
[['or','id=1','id=2'],'(id=1) OR (id=2)',[]],
[['or','type=1',['or','id=1','id=2']],'(type=1) OR ((id=1) OR (id=2))',[]],
// between
[['between','id',1,10],'`id` BETWEEN :qp0 AND :qp1',[':qp0'=>1,':qp1'=>10]],
[['not between','id',1,10],'`id` NOT BETWEEN :qp0 AND :qp1',[':qp0'=>1,':qp1'=>10]],
[['between','date',newExpression('(NOW() - INTERVAL 1 MONTH)'),newExpression('NOW()')],'`date` BETWEEN (NOW() - INTERVAL 1 MONTH) AND NOW()',[]],
[['between','date',newExpression('(NOW() - INTERVAL 1 MONTH)'),123],'`date` BETWEEN (NOW() - INTERVAL 1 MONTH) AND :qp0',[':qp0'=>123]],
[['not between','date',newExpression('(NOW() - INTERVAL 1 MONTH)'),newExpression('NOW()')],'`date` NOT BETWEEN (NOW() - INTERVAL 1 MONTH) AND NOW()',[]],
[['not between','date',newExpression('(NOW() - INTERVAL 1 MONTH)'),123],'`date` NOT BETWEEN (NOW() - INTERVAL 1 MONTH) AND :qp0',[':qp0'=>123]],
// in
[['in','id',[1,2,3]],'`id` IN (:qp0, :qp1, :qp2)',[':qp0'=>1,':qp1'=>2,':qp2'=>3]],
...
...
@@ -194,7 +207,6 @@ class QueryBuilderTest extends DatabaseTestCase
[['in',['id','name'],(newQuery())->select(['id','name'])->from('users')->where(['active'=>1])],'(`id`, `name`) IN (SELECT `id`, `name` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
[['not in',['id','name'],(newQuery())->select(['id','name'])->from('users')->where(['active'=>1])],'(`id`, `name`) NOT IN (SELECT `id`, `name` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
// exists
[['exists',(newQuery())->select('id')->from('users')->where(['active'=>1])],'EXISTS (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
[['not exists',(newQuery())->select('id')->from('users')->where(['active'=>1])],'NOT EXISTS (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
...
...
@@ -209,6 +221,11 @@ class QueryBuilderTest extends DatabaseTestCase