summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-22 01:16:43 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-22 01:16:43 +0000
commit8eb5874e645941473e31525e76d8ce55b39f0135 (patch)
tree6d25d00dc9310287c4b24baadebeb5415c94b573 /modules
parentdc51c88aec0e1685dc9020cc30c05e3131fbde76 (diff)
downloadbrdo-8eb5874e645941473e31525e76d8ce55b39f0135.tar.gz
brdo-8eb5874e645941473e31525e76d8ce55b39f0135.tar.bz2
#1004060 by dmitrig01, chx: Fixed SQLite update queries with expression failing
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/database_test.test19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index b80f55231..65d84c180 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -776,6 +776,25 @@ class DatabaseUpdateTestCase extends DatabaseTestCase {
$this->assertIdentical($num_matches, '1', t('Updated fields successfully.'));
}
+ /**
+ * Test updating with expressions.
+ */
+ function testExpressionUpdate() {
+ // Set age = 1 for a single row for this test to work.
+ db_update('test')
+ ->condition('id', 1)
+ ->fields(array('age' => 1))
+ ->execute();
+
+ // Ensure that expressions are handled properly. This should set every
+ // record's age to a square of itself, which will change only three of the
+ // four records in the table since 1*1 = 1. That means only three records
+ // are modified, so we should get back 3, not 4, from execute().
+ $num_rows = db_update('test')
+ ->expression('age', 'age * age')
+ ->execute();
+ $this->assertIdentical($num_rows, 3, t('Number of affected rows are returned.'));
+ }
}
/**