Use double quotes in GetQueryString()

Fix #923
pull/991/head
John Shahid 2014-09-12 11:09:51 -04:00
parent 169ec22543
commit 9d21359c44
2 changed files with 15 additions and 1 deletions

View File

@ -57,7 +57,7 @@ func (self *FromClause) GetString() string {
if t.Alias != "" {
alias = fmt.Sprintf(" as %s", t.Alias)
}
names = append(names, fmt.Sprintf("%s%s", t.Name.GetString(), alias))
names = append(names, fmt.Sprintf(`"%s"%s`, t.Name.GetString(), alias))
}
buffer.WriteString(strings.Join(names, ","))
}

View File

@ -73,6 +73,20 @@ func (self *QueryParserSuite) TestParseBasicSelectQuery(c *C) {
}
}
func (self *QueryParserSuite) TestGetQueryStringWithDoubleQuotes(c *C) {
q := `select dashboard from "grafana.dashboard_VWx0cmFNUg=="`
query, err := ParseQuery(q)
c.Assert(err, IsNil)
c.Assert(query, HasLen, 1)
actualQ := query[0].GetQueryStringWithTimeCondition()
actualQuery, err := ParseQuery(actualQ)
c.Assert(err, IsNil)
c.Assert(actualQuery, HasLen, 1)
query[0].SelectQuery.startTimeSpecified = false
actualQuery[0].SelectQuery.startTimeSpecified = false
c.Assert(actualQuery, DeepEquals, query)
}
func (self *QueryParserSuite) TestGetQueryString(c *C) {
for _, query := range []string{
"select value from t",