Merge pull request #2033 from yuce/fixes-2009

Fixes #2009
This commit is contained in:
Yuce Tekol 2019-07-09 21:27:10 +03:00 committed by GitHub
commit 430b8a6118
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -253,6 +253,14 @@ func (e *executor) executeCall(ctx context.Context, index string, c *pql.Call, s
return nil, errors.Wrap(err, "validating args")
}
indexTag := fmt.Sprintf("index:%s", index)
// Fixes #2009
// See: https://github.com/pilosa/pilosa/issues/2009
// TODO: Remove at version 2.0
if e.detectRangeCall(c) {
e.Holder.Logger.Printf("DEPRECATED: Range() is deprecated, please use Row() instead.")
}
// Special handling for mutation and top-n calls.
switch c.Name {
case "Sum":
@ -1406,10 +1414,6 @@ func (e *executor) executeRowShard(ctx context.Context, index string, c *pql.Cal
span, _ := tracing.StartSpanFromContext(ctx, "Executor.executeRowShard")
defer span.Finish()
if c.Name == "Range" {
e.Holder.Logger.Printf("DEPRECATED: Range() is deprecated, please use Row() instead.")
}
// Handle bsiGroup ranges differently.
if c.HasConditionArg() {
return e.executeRowBSIGroupShard(ctx, index, c, shard)
@ -2849,6 +2853,21 @@ func (e *executor) translateResult(index string, idx *Index, call *pql.Call, res
return result, nil
}
// detectRangeCall returns true if the call or one of its children contains a Range call
// TODO: Remove at version 2.0
func (e *executor) detectRangeCall(c *pql.Call) bool {
// detect whether there is a Range call
if c.Name == "Range" {
return true
}
for _, c := range c.Children {
if e.detectRangeCall(c) {
return true
}
}
return false
}
// validateQueryContext returns a query-appropriate error if the context is done.
func validateQueryContext(ctx context.Context) error {
select {