Commit 863dd834 authored by Dries's avatar Dries

- Patch #1139638 by DamZ: the SQLite driver cannot update a column to NULL.

parent f5e8a63c
......@@ -101,7 +101,7 @@ public function execute() {
}
elseif (!isset($data)) {
// The field will be set to NULL.
$condition->isNull($field);
$condition->isNotNull($field);
}
else {
$condition->condition($field, $data, '<>');
......
......@@ -718,6 +718,21 @@ class DatabaseUpdateTestCase extends DatabaseTestCase {
$this->assertIdentical($saved_name, 'Tiffany', t('Updated name successfully.'));
}
/**
* Confirm updating to NULL.
*/
function testSimpleNullUpdate() {
$this->ensureSampleDataNull();
$num_updated = db_update('test_null')
->fields(array('age' => NULL))
->condition('name', 'Kermit')
->execute();
$this->assertIdentical($num_updated, 1, t('Updated 1 record.'));
$saved_age = db_query('SELECT age FROM {test_null} WHERE name = :name', array(':name' => 'Kermit'))->fetchField();
$this->assertNull($saved_age, t('Updated name successfully.'));
}
/**
* Confirm that we can update a multiple records successfully.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment