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

CommentFileSizeAuthor
#10 2795919-10.patch961 bytesdaffie
#7 2795919-7.patch1016 bytesdaffie
#4 2795919-4.patch1016 bytesdaffie
#2 2795919-1.patch998 bytesdaffie

Issue fork drupal-2795919

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

daffie created an issue. See original summary.

daffie’s picture

Status: Active » Needs review
StatusFileSize
new998 bytes
daffie’s picture

Status: Needs review » Postponed
Related issues: +#2795967: A query with a fetchAll(\PDO::FETCH_COLUMN) will fail for SQLite.

A SQLite bug surfaced with this issue. Postponed on #2795967: A query with a fetchAll(\PDO::FETCH_COLUMN) will fail for SQLite..

daffie’s picture

StatusFileSize
new1016 bytes

Added an array sort, because there are testbot fails for PostgreSQL without it.

daffie’s picture

Status: Postponed » Needs review

For the testbot.

daffie’s picture

Status: Needs review » Postponed
daffie’s picture

Status: Postponed » Needs review
StatusFileSize
new1016 bytes

If I sort the query result, then the expected result must also be sorted.

daffie’s picture

Status: Needs review » Postponed

The last submitted patch, 4: 2795919-4.patch, failed testing.

daffie’s picture

Status: Postponed » Needs review
StatusFileSize
new961 bytes

Added the sorting to the query.
Removed the array count test. The expected result is an array and has 6 elements.

daffie’s picture

Status: Needs review » Postponed
daffie’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs reroll

This 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

rpayanm made their first commit to this issue’s fork.

rpayanm’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Thanks @rpayanm

quietone’s picture

Title: Drupal\KernelTests\Core\Database\SelectComplexTest has to tests that are exactly the same (testDistinct and testCountQueryDistinct). » Change SelectComplexTest::testDistinct to test the distinct values not the count
Issue summary: View changes

There 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.

alexpott’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 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.

  • alexpott committed 4df74826 on 10.1.x
    Issue #2795919 by daffie, rpayanm: Change SelectComplexTest::...

  • alexpott committed 8c27634a on 10.0.x
    Issue #2795919 by daffie, rpayanm: Change SelectComplexTest::...

  • alexpott committed 6a14cc6f on 9.5.x
    Issue #2795919 by daffie, rpayanm: Change SelectComplexTest::...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.