Skip to content
This repository
Browse code

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
Mark Story authored June 05, 2009
3  cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -275,6 +275,9 @@ function value($data, $column = null, $read = true) {
275 275
 			case 'inet':
276 276
 			case 'float':
277 277
 			case 'integer':
  278
+			case 'date':
  279
+			case 'datetime':
  280
+			case 'timestamp':
278 281
 				if ($data === '') {
279 282
 					return $read ? 'NULL' : 'DEFAULT';
280 283
 				}
15  cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
@@ -291,6 +291,21 @@ function testValueQuoting() {
291 291
 		$this->assertEqual($this->db2->value(null, 'boolean'), "NULL");
292 292
 	}
293 293
 /**
  294
+ * test that date columns do not generate errors with null and nullish values.
  295
+ *
  296
+ * @return void
  297
+ **/
  298
+	function testDateAsNull() {
  299
+		$this->assertEqual($this->db2->value(null, 'date'), 'NULL');
  300
+		$this->assertEqual($this->db2->value('', 'date'), 'NULL');
  301
+
  302
+		$this->assertEqual($this->db2->value('', 'datetime'), 'NULL');
  303
+		$this->assertEqual($this->db2->value(null, 'datetime'), 'NULL');
  304
+
  305
+		$this->assertEqual($this->db2->value('', 'timestamp'), 'NULL');
  306
+		$this->assertEqual($this->db2->value(null, 'timestamp'), 'NULL');
  307
+	}
  308
+/**
294 309
  * Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans
295 310
  *
296 311
  * @access public

0 notes on commit 2c1b7fc

Please sign in to comment.
Something went wrong with that request. Please try again.