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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure correct hasNextPage Value When Relation is Already Loaded #4349

Merged
merged 3 commits into from
Feb 20, 2023

Conversation

calebpowell
Copy link
Contributor

@calebpowell calebpowell commented Feb 17, 2023

This PR removes the overridden ActiveRecordRelationConnection#relation_larger_than method. The overridden method was flawed as demonstrated by the test case on this PR and the parent class implementation appears to return the correct result.

Note that some of the timing related tests are failing for me (but some of them fail on master as well?). It may be that my change introduces additional queries since the some of the prior work done in this area was to address performance. That said, correctness comes first. There is probably a better fix for this issue but I am unfamiliar with the code base 馃槄. Please let me know if this commit would introduce additional issues.

See Issue #4337

Remove the overridden ActiveRecordRelationConnection#relation_larger_than method.
The overridden method was flawed as demonstrated by the test case. The
parent class implementation appears to return the correct result.
@@ -93,10 +101,9 @@ def get_last_cursor(result)
assert_equal(true, conn["pageInfo"]["hasNextPage"])

log_entries = log.split("\n")
assert_equal 2, log_entries.size, "It ran 2 sql queries"
assert_equal 1, log_entries.size, "It should run 1 sql query"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change seems to remove the need for the following query:

SELECT 1 AS one FROM bases WHERE bases.id IN (SELECT bases.id FROM bases WHERE bases.faction_id = ?) LIMIT ? OFFSET ?\e[0m [[faction_id, 2], [LIMIT, 1], [OFFSET, 2]

@rmosolgo
Copy link
Owner

Thanks for this improvement! I think this spec was basically added to document the behavior at the time, so an improvement is very welcome 馃憤

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.

None yet

2 participants