Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding nullish value handling for date, datetime, and timestamp colum…

…n types to DboPostgres. Empty string values now return instead of "". Fixes #6386

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8190 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 2c1b7fc24ed0766975d9b7b461922d6435d6f72c 1 parent 4a076b3
@markstory markstory authored
View
3  cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -275,6 +275,9 @@ function value($data, $column = null, $read = true) {
case 'inet':
case 'float':
case 'integer':
+ case 'date':
+ case 'datetime':
+ case 'timestamp':
if ($data === '') {
return $read ? 'NULL' : 'DEFAULT';
}
View
15 cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
@@ -291,6 +291,21 @@ function testValueQuoting() {
$this->assertEqual($this->db2->value(null, 'boolean'), "NULL");
}
/**
+ * test that date columns do not generate errors with null and nullish values.
+ *
+ * @return void
+ **/
+ function testDateAsNull() {
+ $this->assertEqual($this->db2->value(null, 'date'), 'NULL');
+ $this->assertEqual($this->db2->value('', 'date'), 'NULL');
+
+ $this->assertEqual($this->db2->value('', 'datetime'), 'NULL');
+ $this->assertEqual($this->db2->value(null, 'datetime'), 'NULL');
+
+ $this->assertEqual($this->db2->value('', 'timestamp'), 'NULL');
+ $this->assertEqual($this->db2->value(null, 'timestamp'), 'NULL');
+ }
+/**
* Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans
*
* @access public
Please sign in to comment.
Something went wrong with that request. Please try again.