mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Don't include an equal sign in the string representation of a Condition
This commit is contained in:
parent
b11b8b074d
commit
51ca778d77
2 changed files with 20 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,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 call can be converted into a string.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue