Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
56340bfd
Commit
56340bfd
authored
Nov 07, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(influxdb): fixes bug when using regexps/numbers in tags
closes #6488
parent
16e7bfc6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
+33
-1
pkg/tsdb/influxdb/query_builder.go
+13
-1
pkg/tsdb/influxdb/query_builder_test.go
+20
-0
No files found.
pkg/tsdb/influxdb/query_builder.go
View file @
56340bfd
...
@@ -2,6 +2,7 @@ package influxdb
...
@@ -2,6 +2,7 @@ package influxdb
import
(
import
(
"fmt"
"fmt"
"strconv"
"strings"
"strings"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/grafana/grafana/pkg/tsdb"
...
@@ -42,7 +43,18 @@ func (qb *QueryBuilder) renderTags(query *Query) []string {
...
@@ -42,7 +43,18 @@ func (qb *QueryBuilder) renderTags(query *Query) []string {
str
+=
" "
str
+=
" "
}
}
res
=
append
(
res
,
fmt
.
Sprintf
(
`%s"%s" %s '%s'`
,
str
,
tag
.
Key
,
tag
.
Operator
,
tag
.
Value
))
value
:=
tag
.
Value
nValue
,
err
:=
strconv
.
ParseFloat
(
tag
.
Value
,
64
)
if
tag
.
Operator
==
"=~"
||
tag
.
Operator
==
"!~"
{
value
=
fmt
.
Sprintf
(
"%s"
,
value
)
}
else
if
err
==
nil
{
value
=
fmt
.
Sprintf
(
"%v"
,
nValue
)
}
else
{
value
=
fmt
.
Sprintf
(
"'%s'"
,
value
)
}
res
=
append
(
res
,
fmt
.
Sprintf
(
`%s"%s" %s %s`
,
str
,
tag
.
Key
,
tag
.
Operator
,
value
))
}
}
return
res
return
res
...
...
pkg/tsdb/influxdb/query_builder_test.go
View file @
56340bfd
...
@@ -3,6 +3,8 @@ package influxdb
...
@@ -3,6 +3,8 @@ package influxdb
import
(
import
(
"testing"
"testing"
"strings"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/grafana/grafana/pkg/tsdb"
.
"github.com/smartystreets/goconvey/convey"
.
"github.com/smartystreets/goconvey/convey"
)
)
...
@@ -83,5 +85,23 @@ func TestInfluxdbQueryBuilder(t *testing.T) {
...
@@ -83,5 +85,23 @@ func TestInfluxdbQueryBuilder(t *testing.T) {
So
(
err
,
ShouldBeNil
)
So
(
err
,
ShouldBeNil
)
So
(
rawQuery
,
ShouldEqual
,
`Raw query`
)
So
(
rawQuery
,
ShouldEqual
,
`Raw query`
)
})
})
Convey
(
"can render regex tags"
,
func
()
{
query
:=
&
Query
{
Tags
:
[]
*
Tag
{
&
Tag
{
Operator
:
"=~"
,
Value
:
"value"
,
Key
:
"key"
}}}
So
(
strings
.
Join
(
builder
.
renderTags
(
query
),
""
),
ShouldEqual
,
`"key" =~ value`
)
})
Convey
(
"can render number tags"
,
func
()
{
query
:=
&
Query
{
Tags
:
[]
*
Tag
{
&
Tag
{
Operator
:
"="
,
Value
:
"1"
,
Key
:
"key"
}}}
So
(
strings
.
Join
(
builder
.
renderTags
(
query
),
""
),
ShouldEqual
,
`"key" = 1`
)
})
Convey
(
"can render string tags"
,
func
()
{
query
:=
&
Query
{
Tags
:
[]
*
Tag
{
&
Tag
{
Operator
:
"="
,
Value
:
"value"
,
Key
:
"key"
}}}
So
(
strings
.
Join
(
builder
.
renderTags
(
query
),
""
),
ShouldEqual
,
`"key" = 'value'`
)
})
})
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment