From d6bb5c65de12e22c464fc64799727bc803047a70 Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Tue, 9 Jul 2019 16:41:18 +0300 Subject: [PATCH] Fixes #2009 --- executor.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/executor.go b/executor.go index 7eb13dd79..4b2ff98f4 100644 --- a/executor.go +++ b/executor.go @@ -253,6 +253,13 @@ 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 + 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 +1413,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 +2852,19 @@ func (e *executor) translateResult(index string, idx *Index, call *pql.Call, res return result, nil } +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 {