-
Notifications
You must be signed in to change notification settings - Fork 96
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
Fixes #45, strip sorts from weight check queries #46
Conversation
1c4432c
to
cad78fe
Compare
} | ||
|
||
public LimitSpec withLimit(OptionalInt limit) { | ||
return new LimitSpec(this.columns, limit); |
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.
this
is unnecessary in both withers.
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.
Done
((GroupByQuery) innerQuery).getLimitSpec() | ||
((GroupByQuery) innerQuery).getLimitSpec() == null ? | ||
null : | ||
((GroupByQuery) innerQuery).getLimitSpec().withColumns(new LinkedHashSet<>()) |
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.
Seeing as how we're doing this twice, and all the casting makes for a fairly complex statement, I would suggest extracting this into a helper method:
private LimitSpec extractLimitSpec(GroupByQuery query) {
return query.getLimitSpec() == null ? null : query.getLimitSpec().withColumns(new LinkedHashSet());
}
This will simplify the constructor call to:
...
query.getQueryType() == QueryType.GROUP_BY ? extractLimitSpec((GroupByQuery) query) : null
and this code to:
...
extractLimitSpec((GroupByQuery) innerQuery)
It also means that we can have a positive condition, which is always nice.
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.
You could also have it take a Query
instead, and do the type checking and casting inside the method. Either approach is fine.
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.
Done
GroupByQuery groupByQuery = builder.buildQuery(apiRequest, merger.merge(apiRequest)) | ||
|
||
expect: "The groupBy query has a sort, as a pre-condition" | ||
!groupByQuery.limitSpec.columns.empty |
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.
Since columns
is a collection, you can simplify this using groovy truthiness:
groupByQuery.limitSpec.columns
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.
Done
|
||
and: "The weight-check query doesn't have a sort at either level" | ||
new WeightEvaluationQuery(groupByQuery, 1).limitSpec.columns.empty | ||
new WeightEvaluationQuery(groupByQuery, 1).innermostQuery.limitSpec.columns.empty |
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.
You can do something similar here.
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.
Done
👍 |
} | ||
|
||
public LimitSpec withLimit(OptionalInt limit) { | ||
return new LimitSpec(this.columns, limit); |
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.
It can underline which parameters are pulled from local instance.
I'm warm to andrew's requests. Otherwise 👍 for me. |
b2f91f3
to
ebe14e9
Compare
cad78fe
to
d2a7bef
Compare
ebe14e9
to
bd50d01
Compare
d2a7bef
to
6401722
Compare
4cf7a3d
to
b2141c1
Compare
b2141c1
to
ef3c0eb
Compare
Merged |
Note: Based on other PRs. Once those merge, this PR will be repointed to master.