mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-09 16:57:53 +01:00
ensure postgres boolean values are handled correctly
also fixed an issue with default value loading of bool columns. fixes #3489, fixes #4085, fixes #3920 related to #4672
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace yiiunit\framework\db\pgsql;
|
||||
|
||||
use yii\db\pgsql\Schema;
|
||||
use yii\db\Query;
|
||||
use yiiunit\framework\db\QueryTest;
|
||||
use yiiunit\framework\db\SchemaTest;
|
||||
|
||||
@@ -13,4 +14,27 @@ use yiiunit\framework\db\SchemaTest;
|
||||
class PostgreSQLQueryTest extends QueryTest
|
||||
{
|
||||
public $driverName = 'pgsql';
|
||||
|
||||
public function testBooleanValues()
|
||||
{
|
||||
$db = $this->getConnection();
|
||||
$command = $db->createCommand();
|
||||
$command->batchInsert('bool_values',
|
||||
['bool_col'], [
|
||||
[true],
|
||||
[false],
|
||||
]
|
||||
)->execute();
|
||||
|
||||
$this->assertEquals(1, (new Query())->from('bool_values')->where('bool_col = TRUE')->count('*', $db));
|
||||
$this->assertEquals(1, (new Query())->from('bool_values')->where('bool_col = FALSE')->count('*', $db));
|
||||
$this->assertEquals(2, (new Query())->from('bool_values')->where('bool_col IN (TRUE, FALSE)')->count('*', $db));
|
||||
|
||||
$this->assertEquals(1, (new Query())->from('bool_values')->where(['bool_col' => true])->count('*', $db));
|
||||
$this->assertEquals(1, (new Query())->from('bool_values')->where(['bool_col' => false])->count('*', $db));
|
||||
$this->assertEquals(2, (new Query())->from('bool_values')->where(['bool_col' => [true, false]])->count('*', $db));
|
||||
|
||||
$this->assertEquals(1, (new Query())->from('bool_values')->where('bool_col = :bool_col', ['bool_col' => true])->count('*', $db));
|
||||
$this->assertEquals(1, (new Query())->from('bool_values')->where('bool_col = :bool_col', ['bool_col' => false])->count('*', $db));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user