Skip to content

Commit

Permalink
fix #2224: make influxql keywords case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
dgnorton committed Apr 9, 2015
1 parent 5bfdba0 commit c2b61af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## v0.9.0-rc22 [unreleased]

### Bugfixes
- [#2225](https://github.com/influxdb/influxdb/pull/2225): Make keywords completely case insensitive

### Features
- [#2214](https://github.com/influxdb/influxdb/pull/2214): Added the option to influx CLI to execute single command and exit. Thanks @n1tr0g

Expand Down
1 change: 1 addition & 0 deletions influxql/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func TestScanner_Scan(t *testing.T) {
{s: `WITH`, tok: influxql.WITH},
{s: `WRITE`, tok: influxql.WRITE},
{s: `explain`, tok: influxql.EXPLAIN}, // case insensitive
{s: `seLECT`, tok: influxql.SELECT}, // case insensitive
}

for i, tt := range tests {
Expand Down
4 changes: 1 addition & 3 deletions influxql/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,9 @@ var keywords map[string]Token
func init() {
keywords = make(map[string]Token)
for tok := keyword_beg + 1; tok < keyword_end; tok++ {
keywords[strings.ToUpper(tokens[tok])] = tok
keywords[strings.ToLower(tokens[tok])] = tok
}
for _, tok := range []Token{AND, OR} {
keywords[strings.ToUpper(tokens[tok])] = tok
keywords[strings.ToLower(tokens[tok])] = tok
}
keywords["true"] = TRUE
Expand Down Expand Up @@ -280,7 +278,7 @@ func tokstr(tok Token, lit string) string {

// Lookup returns the token associated with a given string.
func Lookup(ident string) Token {
if tok, ok := keywords[ident]; ok {
if tok, ok := keywords[strings.ToLower(ident)]; ok {
return tok
}
return IDENT
Expand Down

0 comments on commit c2b61af

Please sign in to comment.