diff --git a/pql/ast.go b/pql/ast.go index e01540b84..e26432ad3 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -161,7 +161,14 @@ func (c *Call) String() string { if i > 0 { buf.WriteString(", ") } - fmt.Fprintf(&buf, "%v=%s", key, FormatValue(c.Args[key])) + // If the Arg value is a Condition, then don't include + // the equal sign in the string representation. + switch v := c.Args[key].(type) { + case *Condition: + fmt.Fprintf(&buf, "%v %s", key, v.String()) + default: + fmt.Fprintf(&buf, "%v=%s", key, FormatValue(v)) + } } // Write closing. diff --git a/pql/ast_test.go b/pql/ast_test.go index b8416eccb..9dd3b693f 100644 --- a/pql/ast_test.go +++ b/pql/ast_test.go @@ -29,6 +29,18 @@ func TestCall_String(t *testing.T) { t.Fatalf("unexpected string: %s", s) } }) + t.Run("With Args", func(t *testing.T) { + c := &pql.Call{ + Name: "Range", + Args: map[string]interface{}{ + "frame": "f", + "field0": &pql.Condition{Op: pql.GTE, Value: 10}, + }, + } + if s := c.String(); s != `Range(field0 >= 10, frame="f")` { + t.Fatalf("unexpected string: %s", s) + } + }) } // Ensure condition can handle values for BETWEEN operator.