You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.8 KiB
57 lines
1.8 KiB
11 years ago
|
<?php
|
||
|
namespace yii\tests\unit\framework\db\pgsql;
|
||
|
|
||
|
use yiiunit\framework\db\CommandTest;
|
||
|
|
||
10 years ago
|
/**
|
||
|
* @group db
|
||
|
* @group pgsql
|
||
|
*/
|
||
11 years ago
|
class PostgreSQLCommandTest extends CommandTest
|
||
|
{
|
||
|
public $driverName = 'pgsql';
|
||
11 years ago
|
|
||
|
public function testAutoQuoting()
|
||
|
{
|
||
|
$db = $this->getConnection(false);
|
||
|
|
||
|
$sql = 'SELECT [[id]], [[t.name]] FROM {{customer}} t';
|
||
|
$command = $db->createCommand($sql);
|
||
|
$this->assertEquals('SELECT "id", "t"."name" FROM "customer" t', $command->sql);
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
public function testBooleanValuesInsert()
|
||
10 years ago
|
{
|
||
10 years ago
|
$db = $this->getConnection();
|
||
|
$command = $db->createCommand();
|
||
|
$command->insert('bool_values', ['bool_col' => true]);
|
||
|
$this->assertEquals(1, $command->execute());
|
||
10 years ago
|
|
||
10 years ago
|
$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();
|
||
10 years ago
|
$command->batchInsert('bool_values',
|
||
|
['bool_col'], [
|
||
|
[true],
|
||
|
[false],
|
||
|
]
|
||
|
);
|
||
|
$this->assertEquals(2, $command->execute());
|
||
10 years ago
|
|
||
|
$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());
|
||
10 years ago
|
}
|
||
10 years ago
|
}
|