mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing boolean handling in DboPostgres, closes #4878
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7257 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3552ebea58
commit
3ce765358d
2 changed files with 23 additions and 8 deletions
|
@ -272,12 +272,12 @@ class DboPostgres extends DboSource {
|
|||
$data = pg_escape_bytea($data);
|
||||
break;
|
||||
case 'boolean':
|
||||
if ($data === true) {
|
||||
if ($data === true || $data === 't') {
|
||||
return 'TRUE';
|
||||
} elseif ($data === false) {
|
||||
} elseif ($data === false || $data === 'f') {
|
||||
return 'FALSE';
|
||||
}
|
||||
return 'DEFAULT';
|
||||
return (!empty($data) ? 'TRUE' : 'FALSE');
|
||||
break;
|
||||
default:
|
||||
$data = pg_escape_string($data);
|
||||
|
|
|
@ -281,6 +281,18 @@ class DboPostgresTest extends CakeTestCase {
|
|||
$this->assertEqual($this->db2->value('', 'integer'), "DEFAULT");
|
||||
$this->assertEqual($this->db2->value('', 'float'), "DEFAULT");
|
||||
$this->assertEqual($this->db2->value('0.0', 'float'), "'0.0'");
|
||||
|
||||
$this->assertEqual($this->db2->value('t', 'boolean'), "TRUE");
|
||||
$this->assertEqual($this->db2->value('f', 'boolean'), "FALSE");
|
||||
$this->assertEqual($this->db2->value(true), "TRUE");
|
||||
$this->assertEqual($this->db2->value(false), "FALSE");
|
||||
$this->assertEqual($this->db2->value('t'), "'t'");
|
||||
$this->assertEqual($this->db2->value('f'), "'f'");
|
||||
$this->assertEqual($this->db2->value('', 'boolean'), 'FALSE');
|
||||
$this->assertEqual($this->db2->value(0, 'boolean'), 'FALSE');
|
||||
$this->assertEqual($this->db2->value(1, 'boolean'), 'TRUE');
|
||||
$this->assertEqual($this->db2->value('1', 'boolean'), 'TRUE');
|
||||
$this->assertEqual($this->db2->value(null, 'boolean'), "NULL");
|
||||
}
|
||||
/**
|
||||
* testLastInsertIdMultipleInsert method
|
||||
|
@ -293,6 +305,7 @@ class DboPostgresTest extends CakeTestCase {
|
|||
|
||||
$User =& new User();
|
||||
$db1 = ConnectionManager::getDataSource('test_suite');
|
||||
|
||||
if (PHP5) {
|
||||
$db2 = clone $db1;
|
||||
} else {
|
||||
|
@ -305,13 +318,15 @@ class DboPostgresTest extends CakeTestCase {
|
|||
$db1->truncate($User->useTable);
|
||||
|
||||
$table = $db1->fullTableName($User->useTable, false);
|
||||
$db1->execute("INSERT INTO {$table} (\"user\", password)"
|
||||
. " VALUES ('mariano', '5f4dcc3b5aa765d61d8327deb882cf99')");
|
||||
$db2->execute("INSERT INTO {$table} (\"user\", password)"
|
||||
. " VALUES ('hoge', '5f4dcc3b5aa765d61d8327deb882cf99')");
|
||||
$db1->execute(
|
||||
"INSERT INTO {$table} (\"user\", password) VALUES ('mariano', '5f4dcc3b5aa765d61d8327deb882cf99')"
|
||||
);
|
||||
$db2->execute(
|
||||
"INSERT INTO {$table} (\"user\", password) VALUES ('hoge', '5f4dcc3b5aa765d61d8327deb882cf99')"
|
||||
);
|
||||
$this->assertEqual($db1->lastInsertId($table), 1);
|
||||
$this->assertEqual($db2->lastInsertId($table), 2);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
Loading…
Reference in a new issue