diff --git a/src/integration/data_test.go b/src/integration/data_test.go index c828b53f19a..f101d947cdc 100644 --- a/src/integration/data_test.go +++ b/src/integration/data_test.go @@ -1435,3 +1435,24 @@ func (self *SingleServerSuite) SeriesNameWithWeirdCharacters(c *C) (Fun, Fun) { c.Assert(data[0].Name, Equals, "/blah ( ) ; : ! @ # $ \n \t,foo\"=bar/baz") } } + +// For issue #466 - allow all characters in column names - https://github.com/influxdb/influxdb/issues/267 +func (self *SingleServerSuite) ColumnNameWithWeirdCharacters(c *C) (Fun, Fun) { + return func(client Client) { + data := `[ + { + "name": "foo", + "columns": ["foo.-239(*@&#$!#)(* #$@"], + "points": [[1]] + } + ]` + client.WriteJsonData(data, c, "s") + }, func(client Client) { + data := client.RunQuery("select \"foo.-239(*@&#$!#)(* #$@\" from foo", c) + c.Assert(data, HasLen, 1) + c.Assert(data[0].Points, HasLen, 1) + c.Assert(data[0].Name, Equals, "foo") + c.Assert(data[0].Columns, HasLen, 1) + c.Assert(data[0].Columns[0], Equals, "foo.-239(*@&#$!#)(* #$@") + } +} diff --git a/src/parser/parser_test.go b/src/parser/parser_test.go index d5caa9a563c..b50a1ecf93a 100644 --- a/src/parser/parser_test.go +++ b/src/parser/parser_test.go @@ -865,6 +865,19 @@ func (self *QueryParserSuite) TestParseContinuousQueryList(c *C) { c.Assert(queries[0].IsListContinuousQueriesQuery(), Equals, true) } +// For issue #466 - allow all characters in column names - https://github.com/influxdb/influxdb/issues/267 +func (self *QueryParserSuite) TestParseColumnWithPeriodOrDash(c *C) { + query := "select count(\"column-a.foo\") as \"count-column-a.foo\" from seriesA;" + q, err := ParseSelectQuery(query) + c.Assert(err, IsNil) + c.Assert(q.GetColumnNames(), HasLen, 1) + column := q.GetColumnNames()[0] + c.Assert(column.Name, Equals, "count") + c.Assert(column.Elems, HasLen, 1) + c.Assert(column.Elems[0].Name, Equals, "column-a.foo") + c.Assert(column.Alias, Equals, "count-column-a.foo") +} + // TODO: // insert into user.events.count.per_day select count(*) from user.events where timestring = strdup(yy [a-zA-Z0-9_]* { yylval->string = strdup(yytext); return SIMPLE_NAME; } +\" { BEGIN(IN_SIMPLE_NAME); yylval->string=calloc(1, sizeof(char)); } +\\\" { + yylval->string = realloc(yylval->string, strlen(yylval->string) + 1); + strcat(yylval->string, "\""); +} +\" { + BEGIN(INITIAL); + return SIMPLE_NAME; +} +[^\\"]* { + yylval->string=realloc(yylval->string, strlen(yylval->string) + strlen(yytext) + 1); + strcat(yylval->string, yytext); +} + [a-zA-Z0-9_][a-zA-Z0-9._-]* { yylval->string = strdup(yytext); return TABLE_NAME; } \" { BEGIN(IN_TABLE_NAME); yylval->string=calloc(1, sizeof(char)); }