mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-22 09:40:41 +08:00
fix issue with postgreSQL and batch inserting boolean values
fixes #4654
This commit is contained in:
@@ -20,11 +20,27 @@ class PostgreSQLCommandTest extends CommandTest
|
||||
$this->assertEquals('SELECT "id", "t"."name" FROM "customer" t', $command->sql);
|
||||
}
|
||||
|
||||
public function testBatchInsert()
|
||||
public function testBooleanValuesInsert()
|
||||
{
|
||||
parent::testBatchInsert();
|
||||
$db = $this->getConnection();
|
||||
$command = $db->createCommand();
|
||||
$command->insert('bool_values', ['bool_col' => true]);
|
||||
$this->assertEquals(1, $command->execute());
|
||||
|
||||
$command = $this->getConnection()->createCommand();
|
||||
$command = $db->createCommand();
|
||||
$command->insert('bool_values', ['bool_col' => false]);
|
||||
$this->assertEquals(1, $command->execute());
|
||||
|
||||
$command = $db->createCommand('SELECT COUNT(*) FROM "bool_values" WHERE bool_col = TRUE;');
|
||||
$this->assertEquals(1, $command->queryScalar());
|
||||
$command = $db->createCommand('SELECT COUNT(*) FROM "bool_values" WHERE bool_col = FALSE;');
|
||||
$this->assertEquals(1, $command->queryScalar());
|
||||
}
|
||||
|
||||
public function testBooleanValuesBatchInsert()
|
||||
{
|
||||
$db = $this->getConnection();
|
||||
$command = $db->createCommand();
|
||||
$command->batchInsert('bool_values',
|
||||
['bool_col'], [
|
||||
[true],
|
||||
@@ -32,5 +48,10 @@ class PostgreSQLCommandTest extends CommandTest
|
||||
]
|
||||
);
|
||||
$this->assertEquals(2, $command->execute());
|
||||
|
||||
$command = $db->createCommand('SELECT COUNT(*) FROM "bool_values" WHERE bool_col = TRUE;');
|
||||
$this->assertEquals(1, $command->queryScalar());
|
||||
$command = $db->createCommand('SELECT COUNT(*) FROM "bool_values" WHERE bool_col = FALSE;');
|
||||
$this->assertEquals(1, $command->queryScalar());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user