? sites/default/modules ? sites/default/settings.php Index: modules/simpletest/tests/database_test.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/database_test.test,v retrieving revision 1.9 diff -u -p -r1.9 database_test.test --- modules/simpletest/tests/database_test.test 28 Sep 2008 21:52:08 -0000 1.9 +++ modules/simpletest/tests/database_test.test 2 Oct 2008 05:56:19 -0000 @@ -486,6 +486,18 @@ class DatabaseInsertLOBTestCase extends } /** + * Test that we can insert an empty blob field successfully. + */ + function testInsertEmptyBlob() { + $data = ''; + $this->assertTrue($data === '', t('Test data is an empty string.')); + $id = db_insert('test_one_blob')->fields(array('blob1' => $data))->execute(); + $res = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id)); + $r = db_fetch_array($res); + $this->assertTrue($r['blob1'] === $data, t('Can insert an empty blob: id @id, type @type, @data.', array('@id' => $id, '@type' => gettype($r['blob1']), '@data' => serialize($r)))); + } + + /** * Test that we can insert multiple blob fields in the same query. */ function testInsertMultipleBlob() { @@ -766,6 +778,23 @@ class DatabaseUpdateLOBTestCase extends } /** + * Confirm that we can update an empty blob column. + */ + function testUpdateEmptyBlob() { + $data = "This is\000a test."; + $this->assertTrue(strlen($data) === 15, t('Test data contains a NULL.')); + $id = db_insert('test_one_blob')->fields(array('blob1' => $data))->execute(); + + $data = ''; + $this->assertTrue($data === '', t('Test data is an empty string.')); + db_update('test_one_blob')->condition('id', $id)->fields(array('blob1' => $data))->execute(); + + $res = db_query('SELECT * FROM {test_one_blob} WHERE id = %d', $id); + $r = db_fetch_array($res); + $this->assertTrue($r['blob1'] === $data, t('Can update an empty blob: id @id, type @type, @data.', array('@id' => $id, '@type' => gettype($r['blob1']), '@data' => serialize($r)))); + } + + /** * Confirm that we can update two blob columns in the same table. */ function testUpdateMultipleBlob() {