@@ -201,12 +201,6 @@ class QueryBuilderTest extends DatabaseTestCase
...
@@ -201,12 +201,6 @@ class QueryBuilderTest extends DatabaseTestCase
[['in','id',(newQuery())->select('id')->from('users')->where(['active'=>1])],'(`id`) IN (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
[['in','id',(newQuery())->select('id')->from('users')->where(['active'=>1])],'(`id`) IN (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
[['not in','id',(newQuery())->select('id')->from('users')->where(['active'=>1])],'(`id`) NOT IN (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
[['not in','id',(newQuery())->select('id')->from('users')->where(['active'=>1])],'(`id`) NOT IN (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
// composite in
[['in',['id','name'],[['id'=>1,'name'=>'foo'],['id'=>2,'name'=>'bar']]],'(`id`, `name`) IN ((:qp0, :qp1), (:qp2, :qp3))',[':qp0'=>1,':qp1'=>'foo',':qp2'=>2,':qp3'=>'bar']],
[['not in',['id','name'],[['id'=>1,'name'=>'foo'],['id'=>2,'name'=>'bar']]],'(`id`, `name`) NOT IN ((:qp0, :qp1), (:qp2, :qp3))',[':qp0'=>1,':qp1'=>'foo',':qp2'=>2,':qp3'=>'bar']],
[['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
[['exists',(newQuery())->select('id')->from('users')->where(['active'=>1])],'EXISTS (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
[['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]],
[['not exists',(newQuery())->select('id')->from('users')->where(['active'=>1])],'NOT EXISTS (SELECT `id` FROM `users` WHERE `active`=:qp0)',[':qp0'=>1]],
...
@@ -228,6 +222,23 @@ class QueryBuilderTest extends DatabaseTestCase
...
@@ -228,6 +222,23 @@ class QueryBuilderTest extends DatabaseTestCase
];
];
switch($this->driverName){
default:
$conditions=array_merge($conditions,[
[['in',['id','name'],[['id'=>1,'name'=>'foo'],['id'=>2,'name'=>'bar']]],'((`id` = :qp0 AND `name` = :qp1) OR (`id` = :qp2 AND `name` = :qp3))',[':qp0'=>1,':qp1'=>'foo',':qp2'=>2,':qp3'=>'bar']],
[['not in',['id','name'],[['id'=>1,'name'=>'foo'],['id'=>2,'name'=>'bar']]],'((`id` != :qp0 OR `name` != :qp1) AND (`id` != :qp2 OR `name` != :qp3))',[':qp0'=>1,':qp1'=>'foo',':qp2'=>2,':qp3'=>'bar']],
]);
break;
case'pgsql':
$conditions=array_merge($conditions,[
[['in',['id','name'],[['id'=>1,'name'=>'foo'],['id'=>2,'name'=>'bar']]],'(`id`, `name`) IN ((:qp0, :qp1), (:qp2, :qp3))',[':qp0'=>1,':qp1'=>'foo',':qp2'=>2,':qp3'=>'bar']],
[['not in',['id','name'],[['id'=>1,'name'=>'foo'],['id'=>2,'name'=>'bar']]],'(`id`, `name`) NOT IN ((:qp0, :qp1), (:qp2, :qp3))',[':qp0'=>1,':qp1'=>'foo',':qp2'=>2,':qp3'=>'bar']],
[['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]],