-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix: Add a check to ensure limit is not 0 when evaluating query limit and offset #706
Conversation
@jsimnz the fix is a little different than what you suggested. Decided on not changing the node limit directly and rather just check that it's not 0. This avoids the large int64 in the explain response. |
makes sense |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
query/graphql/planner/limit.go
Outdated
limitLabel: n.limit, | ||
exp := map[string]interface{}{ | ||
offsetLabel: n.offset, | ||
}, nil | ||
} | ||
|
||
if n.limit != 0 { | ||
exp[limitLabel] = n.limit | ||
} | ||
|
||
return exp, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion(blocking): I disagree with this change. Every implementation of Explain right now dumps a fixed number of attributes. n.limit
attribute is the most important attribute in both the "limitNodes
". Furthermore the current implementation of explain is also considered the v1(i.e. verbose=true) and if we want to have a different number of attributes depending on certain situations those need to be first thought out for every explain node and be handled in a verbose = false
feature. Please revert this change.
query/graphql/planner/limit.go
Outdated
limitLabel: n.limit, | ||
exp := map[string]interface{}{ | ||
offsetLabel: n.offset, | ||
}, nil | ||
} | ||
|
||
if n.limit != 0 { | ||
exp[limitLabel] = n.limit | ||
} | ||
|
||
return exp, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion(blocking): Similar comment as above.
@@ -138,7 +138,6 @@ func TestExplainQueryWithOnlyOffsetSpecified(t *testing.T) { | |||
"explain": dataMap{ | |||
"selectTopNode": dataMap{ | |||
"hardLimitNode": dataMap{ | |||
"limit": int64(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion(blocking): Following the above comments is an important attribute, please leave in.
@@ -528,7 +527,6 @@ func TestExplainQueryWithOnlyOffsetOnChild(t *testing.T) { | |||
"subType": dataMap{ | |||
"selectTopNode": dataMap{ | |||
"hardLimitNode": dataMap{ | |||
"limit": int64(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion(blocking): Following the above comments is an important attribute, please leave in.
func TestQuerySimpleWithOffset(t *testing.T) { | ||
tests := []testUtils.QueryTestCase{ | ||
{ | ||
Description: "Simple query with basic offset", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick:
func TestQuerySimpleWithOffset(t *testing.T) { | |
tests := []testUtils.QueryTestCase{ | |
{ | |
Description: "Simple query with basic offset", | |
func TestQuerySimpleWithOnlyOffset(t *testing.T) { | |
tests := []testUtils.QueryTestCase{ | |
{ | |
Description: "Simple query with only offset", |
}, | ||
}, | ||
{ | ||
Description: "Simple query with basic offset, more rows", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: basic seems generic to me, perhaps use of only
can signal that you are testing the case without limit.
Description: "Simple query with basic offset, more rows", | |
Description: "Simple query with only offset, more rows", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick solution. Mainly concerned about the explain deleting the n.limit
attribute in certain conditions mostly because current explain should dump attribute of interest as is.
5f2142c
to
9d772b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Don't forget to update the PR Description:
This also removes the "limit": 0 object from the explain response when there is no limit.
Codecov Report
@@ Coverage Diff @@
## develop #706 +/- ##
===========================================
+ Coverage 57.39% 57.42% +0.02%
===========================================
Files 143 143
Lines 16398 16408 +10
===========================================
+ Hits 9412 9422 +10
Misses 6102 6102
Partials 884 884
|
… and offset (sourcenetwork#706) Relevant issue(s) Resolves sourcenetwork#705 Description This PR solves a situation where setting an offset to the query without setting a limit would yield a single result.
Relevant issue(s)
Resolves #705
Resolves #620
Description
This PR solves a situation where setting an offset to the query without setting a limit would yield a single result.
Tasks
How has this been tested?
integration testing
Specify the platform(s) on which this was tested: