Browse Source

Fix null bytea columns.

Apply patch from 'opiazer'  Fixes #2432
mark_story 14 years ago
parent
commit
c43b099894

+ 1 - 1
lib/Cake/Model/Datasource/Database/Postgres.php

@@ -716,7 +716,7 @@ class Postgres extends DboSource {
 					break;
 					case 'binary':
 					case 'bytea':
-						$resultRow[$table][$column] = stream_get_contents($row[$index]);
+						$resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]);
 					break;
 					default:
 						$resultRow[$table][$column] = $row[$index];

+ 1 - 1
lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php

@@ -759,7 +759,7 @@ class PostgresTest extends CakeTestCase {
  */
 	function testVirtualFieldAsAConstant() {
 		$this->loadFixtures('Article', 'Comment');
-		$Article =& ClassRegistry::init('Article');
+		$Article = ClassRegistry::init('Article');
 		$Article->virtualFields = array(
 			'empty' => "NULL",
 			'number' => 43,