Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Tweak some test to account for slightly different sorting logic in PostgreSQL #10693

Conversation

maxime-rainville
Copy link
Contributor

Queries without a ORDER BY clause in PostgreSQL are return in a slightly different order. This leads to somewhat different results in some context.

Parent issue

silverstripe/silverstripe-postgresql#143

$list = $list->sort($emtpyValue);
$this->assertSame(['Subteam 1'], $list->limit(1)->column('Title'));
}

public function provideSortScalarValues(): array
{
return [
[null, 'wipes-existing'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario was testing that calling sort with null unsets the order by clause. I've replaced it with a sightly different test below.

@@ -1831,7 +1831,7 @@ public function testMapInCMSGroups(array $groupFixtures, array $groupCodes, arra
$result = Member::mapInCMSGroups($groups);
$this->assertInstanceOf(Map::class, $result);

$this->assertSame($expectedUsers, $result->keys());
$this->assertEqualsCanonicalizing($expectedUsers, $result->keys());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PostgreSQL, the result was returning the keys in a slightly different order.

The order of the results is irrelevant here. `assertEqualsCanonicalizing' sorts the arrays before comparing them.

@dhensby dhensby merged commit bf058ee into silverstripe:5.0 Feb 18, 2023
@GuySartorelli GuySartorelli deleted the pulls/5.0/tweak-test-for-postgresql branch February 18, 2023 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants