Fixing issues in postgres with time columns and '' values.

Tests added.
Fixes #213
This commit is contained in:
mark_story 2009-10-27 13:22:34 -04:00
parent 79fdd8b341
commit 5a093e5627
2 changed files with 6 additions and 2 deletions

View file

@ -286,6 +286,7 @@ class DboPostgres extends DboSource {
case 'date':
case 'datetime':
case 'timestamp':
case 'time':
if ($data === '') {
return $read ? 'NULL' : 'DEFAULT';
}

View file

@ -291,11 +291,11 @@ class DboPostgresTest extends CakeTestCase {
$this->assertEqual($this->db2->value(null, 'boolean'), "NULL");
}
/**
* test that date columns do not generate errors with null and nullish values.
* test that date and time columns do not generate errors with null and nullish values.
*
* @return void
**/
function testDateAsNull() {
function testDateAndTimeAsNull() {
$this->assertEqual($this->db2->value(null, 'date'), 'NULL');
$this->assertEqual($this->db2->value('', 'date'), 'NULL');
@ -304,6 +304,9 @@ class DboPostgresTest extends CakeTestCase {
$this->assertEqual($this->db2->value('', 'timestamp'), 'NULL');
$this->assertEqual($this->db2->value(null, 'timestamp'), 'NULL');
$this->assertEqual($this->db2->value('', 'time'), 'NULL');
$this->assertEqual($this->db2->value(null, 'time'), 'NULL');
}
/**
* Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans