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

Address occasional test_pluck_columns_with_same_name failure #36378

Merged
merged 1 commit into from
Jun 2, 2019

Conversation

yahonda
Copy link
Member

@yahonda yahonda commented Jun 2, 2019

Summary

This pull request addresses test_pluck_columns_with_same_name failure due to non deterministic sort order. This failure is occasional, does not always reproduce.

$ bundle exec rake test_postgresql
... snip ...
Failure:
CalculationsTest#test_pluck_columns_with_same_name [/home/yahonda/git/rails/activerecord/test/cases/calculations_test.rb:842]:
--- expected
+++ actual
@@ -1 +1 @@
-[["The First Topic", "The Second Topic of the day"], ["The Third Topic of the day", "The Fourth Topic of the day"]]
+[["The Third Topic of the day", "The Fourth Topic of the day"], ["The First Topic", "The Second Topic of the day"]]

@@ -838,7 +838,7 @@ def test_pluck_replaces_select_clause
def test_pluck_columns_with_same_name
expected = [["The First Topic", "The Second Topic of the day"], ["The Third Topic of the day", "The Fourth Topic of the day"]]
actual = Topic.joins(:replies)
Copy link
Member

Choose a reason for hiding this comment

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

How about adding order(:id)?
It is coincidental that id:1's title and id:3's title are alphabetical order.

Suggested change
actual = Topic.joins(:replies)
actual = Topic.joins(:replies).order(:id)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review. Updated.
I should have referred the test test_pluck_replaces_select_clause above which also specifies order using order(:id).

…stic sort order

```ruby
$ bundle exec rake test_postgresql
... snip ...
Failure:
CalculationsTest#test_pluck_columns_with_same_name [/home/yahonda/git/rails/activerecord/test/cases/calculations_test.rb:842]:
--- expected
+++ actual
@@ -1 +1 @@
-[["The First Topic", "The Second Topic of the day"], ["The Third Topic of the day", "The Fourth Topic of the day"]]
+[["The Third Topic of the day", "The Fourth Topic of the day"], ["The First Topic", "The Second Topic of the day"]]
```
@yahonda yahonda force-pushed the test_pluck_columns_with_same_name branch from afc4262 to 86384ea Compare June 2, 2019 07:10
@kamipo kamipo merged commit 9374c5b into rails:master Jun 2, 2019
kamipo added a commit that referenced this pull request Nov 19, 2019
Address occasional test_pluck_columns_with_same_name failure
JesseChavez pushed a commit to JesseChavez/rails that referenced this pull request Dec 19, 2019
…ame_name

Address occasional test_pluck_columns_with_same_name failure
@yahonda yahonda deleted the test_pluck_columns_with_same_name branch January 2, 2022 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants