mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #844 from travisturner/bug-fix-condition-string
Don't include an equal sign in the string representation of a Condition
This commit is contained in:
commit
1fb540f40b
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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue