summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-22 08:13:58 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-22 08:13:58 +0000
commit1eb122344a6b383741265228cd2a286dc94ee8de (patch)
tree4ac87ea108a74281bc169c69f65e64fa43083f0f /modules
parentd65e0e385302ade07cd526166be9010a30de062b (diff)
downloadbrdo-1eb122344a6b383741265228cd2a286dc94ee8de.tar.gz
brdo-1eb122344a6b383741265228cd2a286dc94ee8de.tar.bz2
#1003860 by dmitrig01, chx: Fixed Count query fails to remove fields and expressions.
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 65d84c180..db74bd9e5 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1989,6 +1989,25 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$this->assertEqual($count, 4, t('Counted the correct number of records.'));
}
+
+ /**
+ * Test that countQuery properly removes fields and expressions.
+ */
+ function testCountQueryFieldRemovals() {
+ // countQuery should remove all fields and expressions, so this can be
+ // tested by adding a non-existant field and expression: if it ends
+ // up in the query, an error will be thrown. If not, it will return the
+ // number of records, which in this case happens to be 4 (there are four
+ // records in the {test} table).
+ $query = db_select('test');
+ $query->fields('test', array('fail'));
+ $this->assertEqual(4, $query->countQuery()->execute()->fetchField(), t('Count Query removed fields'));
+
+ $query = db_select('test');
+ $query->addExpression('fail');
+ $this->assertEqual(4, $query->countQuery()->execute()->fetchField(), t('Count Query removed expressions'));
+ }
+
/**
* Test that we can generate a count query from a query with distinct.
*/