Skip to content
This repository
Browse code

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

Tests added.
Fixes #213
  • Loading branch information...
commit 5a093e56272d614c7bb33adee0eb4dfd3cc701c1 1 parent 79fdd8b
Mark Story authored
1  cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -286,6 +286,7 @@ function value($data, $column = null, $read = true) {
286 286
 			case 'date':
287 287
 			case 'datetime':
288 288
 			case 'timestamp':
  289
+			case 'time':
289 290
 				if ($data === '') {
290 291
 					return $read ? 'NULL' : 'DEFAULT';
291 292
 				}
7  cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
@@ -291,11 +291,11 @@ 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.
  294
+ * test that date and time columns do not generate errors with null and nullish values.
295 295
  *
296 296
  * @return void
297 297
  **/
298  
-	function testDateAsNull() {
  298
+	function testDateAndTimeAsNull() {
299 299
 		$this->assertEqual($this->db2->value(null, 'date'), 'NULL');
300 300
 		$this->assertEqual($this->db2->value('', 'date'), 'NULL');
301 301
 
@@ -304,6 +304,9 @@ function testDateAsNull() {
304 304
 
305 305
 		$this->assertEqual($this->db2->value('', 'timestamp'), 'NULL');
306 306
 		$this->assertEqual($this->db2->value(null, 'timestamp'), 'NULL');
  307
+
  308
+		$this->assertEqual($this->db2->value('', 'time'), 'NULL');
  309
+		$this->assertEqual($this->db2->value(null, 'time'), 'NULL');
307 310
 	}
308 311
 /**
309 312
  * Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans

0 notes on commit 5a093e5

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