summaryrefslogtreecommitdiffstatshomepage
path: root/modules/simpletest/tests/database_test.test
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-08-22 03:27:53 +0100
committerwebchick <webchick@24967.no-reply.drupal.org>2011-08-22 03:27:53 +0100
commite8164832e40f5b58aa2b7bc4cc5b8eb27d05c751 (patch)
treef20a714e1bbf88e786092224b6099104f78fd5b5 /modules/simpletest/tests/database_test.test
parentfa456923c71514502ddbcf8dd16d32e106c9df0f (diff)
downloaddrupal-e8164832e40f5b58aa2b7bc4cc5b8eb27d05c751.tar.gz
drupal-e8164832e40f5b58aa2b7bc4cc5b8eb27d05c751.zip
Issue #1112854 by dereine, chx, Damien Tournoud: Fixed Subqueries use wrong arguments.
Diffstat (limited to 'modules/simpletest/tests/database_test.test')
-rw-r--r--modules/simpletest/tests/database_test.test34
1 files changed, 20 insertions, 14 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index e27693c9753..76ca1038e05 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1629,22 +1629,28 @@ class DatabaseSelectSubqueryTestCase extends DatabaseTestCase {
$subquery->addField('tt', 'task', 'task');
$subquery->condition('priority', 1);
- // Create another query that joins against the virtual table resulting
- // from the subquery.
- $select = db_select($subquery, 'tt2');
- $select->join('test', 't', 't.id=tt2.pid');
- $select->addField('t', 'name');
+ for ($i = 0; $i < 2; $i++) {
+ // Create another query that joins against the virtual table resulting
+ // from the subquery.
+ $select = db_select($subquery, 'tt2');
+ $select->join('test', 't', 't.id=tt2.pid');
+ $select->addField('t', 'name');
+ if ($i) {
+ // Use a different number of conditions here to confuse the subquery
+ // placeholder counter, testing http://drupal.org/node/1112854.
+ $select->condition('name', 'John');
+ }
+ $select->condition('task', 'code');
- $select->condition('task', 'code');
+ // The resulting query should be equivalent to:
+ // SELECT t.name
+ // FROM (SELECT tt.pid AS pid, tt.task AS task FROM test_task tt WHERE priority=1) tt
+ // INNER JOIN test t ON t.id=tt.pid
+ // WHERE tt.task = 'code'
+ $people = $select->execute()->fetchCol();
- // The resulting query should be equivalent to:
- // SELECT t.name
- // FROM (SELECT tt.pid AS pid, tt.task AS task FROM test_task tt WHERE priority=1) tt
- // INNER JOIN test t ON t.id=tt.pid
- // WHERE tt.task = 'code'
- $people = $select->execute()->fetchCol();
-
- $this->assertEqual(count($people), 1, t('Returned the correct number of rows.'));
+ $this->assertEqual(count($people), 1, t('Returned the correct number of rows.'));
+ }
}
/**