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:
Ben Tasker
2023-11-15 11:21:41 +00:00
committed by GitHub
parent 4ebfce8b9a
commit c06debe200
5 changed files with 53 additions and 4 deletions

View File

@@ -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, `\`, `\\`))

View File

@@ -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"}}}