Problem/Motivation
Drupal\KernelTests\Core\Database\SelectComplexTest has to tests that are exactly the same (testDistinct and testCountQueryDistinct).
The code for Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct:
$query = db_select('test_task');
$query->addField('test_task', 'task');
$query->distinct();
$query_result = $query->countQuery()->execute()->fetchField();
$this->assertEqual($query_result, 6, 'Returned the correct number of rows.');
The code for Drupal\KernelTests\Core\Database\SelectComplexTest::testCountQueryDistinct:
$query = db_select('test_task');
$query->addField('test_task', 'task');
$query->distinct();
$count = $query->countQuery()->execute()->fetchField();
$this->assertEqual($count, 6, 'Counted the correct number of records.');
Steps to reproduce
Proposed resolution
Lets change the code for Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct to:
$query = db_select('test_task');
$query->addField('test_task', 'task');
$query->distinct();
$query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);
$this->assertEqual(count($query_result), 6, 'Returned the correct number of rows.');
$correct_result = ['eat', 'sleep', 'code', 'sing', 'found new band', 'perform at superbowl'];
$this->assertEqual($query_result, $correct_result, 'Returned the correct number of rows.');
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comments
Comment #2
daffie commentedComment #3
daffie commentedA SQLite bug surfaced with this issue. Postponed on #2795967: A query with a fetchAll(\PDO::FETCH_COLUMN) will fail for SQLite..
Comment #4
daffie commentedAdded an array sort, because there are testbot fails for PostgreSQL without it.
Comment #5
daffie commentedFor the testbot.
Comment #6
daffie commentedComment #7
daffie commentedIf I sort the query result, then the expected result must also be sorted.
Comment #8
daffie commentedComment #10
daffie commentedAdded the sorting to the query.
Removed the array count test. The expected result is an array and has 6 elements.
Comment #11
daffie commentedComment #12
daffie commented#2795967: A query with a fetchAll(\PDO::FETCH_COLUMN) will fail for SQLite. has landed.
Comment #25
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge require as a guide.
Needs a reroll for 10.1
Comment #28
rpayanmComment #29
smustgrave commentedThanks @rpayanm
Comment #30
quietone commentedThere was a typo in the title which I came to fix. But after reading the IS and the patch I changed the title to what this is actually doing.
Comment #31
alexpottCommitted and pushed 4df7482665 to 10.1.x and 8c27634a0e to 10.0.x and 6a14cc6fda to 9.5.x. Thanks!
Backported to 9.5.x as a test only change.