mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
InfluxDB: Add support for >= and <= comparison operators to IQL Query Builder (#77917)
* InfluxDB: Add support for `>=` and `<=` comparison operators to InfluxQL Query Builder * Add front-end support for the new operators This ensures that the query translates correctly between raw and builder mode * Chore: add test for new operators * chore: add front-end tests * fix: don't skip quoting on `<>` This preserves the pre-existing behaviour, fixing a failing test * chore: fix tests
This commit is contained in:
@@ -72,7 +72,7 @@ func (query *Query) renderTags() []string {
|
||||
switch tag.Operator {
|
||||
case "=~", "!~":
|
||||
textValue = tag.Value
|
||||
case "<", ">":
|
||||
case "<", ">", ">=", "<=":
|
||||
textValue = tag.Value
|
||||
default:
|
||||
textValue = fmt.Sprintf("'%s'", strings.ReplaceAll(tag.Value, `\`, `\\`))
|
||||
|
||||
@@ -228,6 +228,17 @@ func TestInfluxdbQueryBuilder(t *testing.T) {
|
||||
require.Equal(t, strings.Join(query.renderTags(), ""), `"key" > 10001`)
|
||||
})
|
||||
|
||||
t.Run("can render number greater than or equal to condition tags", func(t *testing.T) {
|
||||
query := &Query{Tags: []*Tag{{Operator: ">=", Value: "10001", Key: "key"}}}
|
||||
|
||||
require.Equal(t, strings.Join(query.renderTags(), ""), `"key" >= 10001`)
|
||||
})
|
||||
t.Run("can render number less than or equal to condition tags", func(t *testing.T) {
|
||||
query := &Query{Tags: []*Tag{{Operator: "<=", Value: "10001", Key: "key"}}}
|
||||
|
||||
require.Equal(t, strings.Join(query.renderTags(), ""), `"key" <= 10001`)
|
||||
})
|
||||
|
||||
t.Run("can render string tags", func(t *testing.T) {
|
||||
query := &Query{Tags: []*Tag{{Operator: "=", Value: "value", Key: "key"}}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user