fix issue with postgreSQL and batch inserting boolean values

fixes #4654
This commit is contained in:
Carsten Brandt
2014-08-12 01:42:08 +02:00
parent f1dd83e2a9
commit 92d65ab78b
4 changed files with 68 additions and 4 deletions

View File

@ -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());
}
}