mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
InfluxDB: Update InfluxQL querybuilder to qualify identifiers (#62230)
This commit is contained in:
@@ -78,7 +78,17 @@ func (query *Query) renderTags() []string {
|
||||
textValue = fmt.Sprintf("'%s'", strings.ReplaceAll(tag.Value, `\`, `\\`))
|
||||
}
|
||||
|
||||
res = append(res, fmt.Sprintf(`%s"%s" %s %s`, str, tag.Key, tag.Operator, textValue))
|
||||
escapedKey := fmt.Sprintf(`"%s"`, tag.Key)
|
||||
|
||||
if strings.HasSuffix(tag.Key, "::tag") {
|
||||
escapedKey = fmt.Sprintf(`"%s"::tag`, strings.TrimSuffix(tag.Key, "::tag"))
|
||||
}
|
||||
|
||||
if strings.HasSuffix(tag.Key, "::field") {
|
||||
escapedKey = fmt.Sprintf(`"%s"::field`, strings.TrimSuffix(tag.Key, "::field"))
|
||||
}
|
||||
|
||||
res = append(res, fmt.Sprintf(`%s%s %s %s`, str, escapedKey, tag.Operator, textValue))
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
@@ -98,10 +98,23 @@ func init() {
|
||||
}
|
||||
|
||||
func fieldRenderer(query *Query, queryContext *backend.QueryDataRequest, part *QueryPart, innerExpr string) string {
|
||||
if part.Params[0] == "*" {
|
||||
param := part.Params[0]
|
||||
|
||||
if param == "*" {
|
||||
return "*"
|
||||
}
|
||||
return fmt.Sprintf(`"%s"`, part.Params[0])
|
||||
|
||||
escapedParam := fmt.Sprintf(`"%s"`, param)
|
||||
|
||||
if strings.HasSuffix(param, "::tag") {
|
||||
escapedParam = fmt.Sprintf(`"%s"::tag`, strings.TrimSuffix(param, "::tag"))
|
||||
}
|
||||
|
||||
if strings.HasSuffix(param, "::field") {
|
||||
escapedParam = fmt.Sprintf(`"%s"::field`, strings.TrimSuffix(param, "::field"))
|
||||
}
|
||||
|
||||
return escapedParam
|
||||
}
|
||||
|
||||
func functionRenderer(query *Query, queryContext *backend.QueryDataRequest, part *QueryPart, innerExpr string) string {
|
||||
|
||||
Reference in New Issue
Block a user