Commit 6d84974f authored by webchick's avatar webchick

#343620 by Dave Reid: Fix db_update() failure on expression-only SQL (with test).

parent da3a3ac7
......@@ -793,7 +793,7 @@ class UpdateQuery extends Query implements QueryConditionInterface {
*
* @var array
*/
protected $fields;
protected $fields = array();
/**
* An array of values to update to.
......
......@@ -799,6 +799,21 @@ class DatabaseUpdateComplexTestCase extends DatabaseTestCase {
$this->assertTrue(FALSE, $e->getMessage());
}
}
/**
* Test update with only expression values.
*/
function testUpdateOnlyExpression() {
$before_age = db_query("SELECT age FROM {test} WHERE name = 'Ringo'")->fetchField();
$num_updated = db_update('test')
->condition('name', 'Ringo')
->expression('age', 'age + :age',array(':age' => 4))
->execute();
$this->assertIdentical($num_updated, 1, t('Updated 1 record.'));
$after_age = db_query("SELECT age FROM {test} WHERE name = 'Ringo'")->fetchField();
$this->assertEqual($before_age + 4, $after_age, t('Age updated correctly'));
}
}
/**
......
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