Merge pull request #8845 from influxdata/amh-8789
Fix CLI to allow quoted database namespull/8971/head^2
commit
1d9a765084
|
@ -17,6 +17,7 @@
|
|||
- [#9109](https://github.com/influxdata/influxdb/issues/9109): Fix: panic: sync: WaitGroup is reused before previous Wait has returned
|
||||
- [#9163](https://github.com/influxdata/influxdb/pull/9163): Fix race condition in the merge iterator close method.
|
||||
- [#9144](https://github.com/influxdata/influxdb/issues/9144): Fix query compilation so multiple nested distinct calls is allowable
|
||||
- [#8789](https://github.com/influxdata/influxdb/issues/8789): Fix CLI to allow quoted database names in use statement
|
||||
|
||||
## v1.4.2 [2017-11-15]
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ func (c *CommandLine) clear(cmd string) {
|
|||
}
|
||||
|
||||
func (c *CommandLine) use(cmd string) {
|
||||
args := strings.Split(strings.TrimSuffix(strings.TrimSpace(cmd), ";"), " ")
|
||||
args := strings.SplitAfterN(strings.TrimSuffix(strings.TrimSpace(cmd), ";"), " ", 2)
|
||||
if len(args) != 2 {
|
||||
fmt.Printf("Could not parse database name from %q.\n", cmd)
|
||||
return
|
||||
|
@ -418,6 +418,7 @@ func (c *CommandLine) use(cmd string) {
|
|||
}
|
||||
|
||||
if !c.databaseExists(db) {
|
||||
fmt.Println("DB does not exist!")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -426,13 +426,16 @@ func TestParseCommand_Use(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
cmd string
|
||||
db string
|
||||
}{
|
||||
{cmd: "use db"},
|
||||
{cmd: " use db"},
|
||||
{cmd: "use db "},
|
||||
{cmd: "use db;"},
|
||||
{cmd: "use db; "},
|
||||
{cmd: "Use db"},
|
||||
{cmd: "use db", db: "db"},
|
||||
{cmd: " use db", db: "db"},
|
||||
{cmd: "use db ", db: "db"},
|
||||
{cmd: "use db;", db: "db"},
|
||||
{cmd: "use db; ", db: "db"},
|
||||
{cmd: "Use db", db: "db"},
|
||||
{cmd: `Use "db"`, db: "db"},
|
||||
{cmd: `Use "db db"`, db: "db db"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
@ -441,8 +444,8 @@ func TestParseCommand_Use(t *testing.T) {
|
|||
t.Fatalf(`Got error %v for command %q, expected nil.`, err, test.cmd)
|
||||
}
|
||||
|
||||
if m.Database != "db" {
|
||||
t.Fatalf(`Command "use" changed database to %q. Expected db`, m.Database)
|
||||
if m.Database != test.db {
|
||||
t.Fatalf(`Command "%s" changed database to %q. Expected %s`, test.cmd, m.Database, test.db)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -656,7 +659,7 @@ func emptyTestServer() *httptest.Server {
|
|||
switch stmt.(type) {
|
||||
case *influxql.ShowDatabasesStatement:
|
||||
if authorized {
|
||||
io.WriteString(w, `{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["db"]]}]}]}`)
|
||||
io.WriteString(w, `{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["db", "db db"]]}]}]}`)
|
||||
} else {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
io.WriteString(w, fmt.Sprintf(`{"error":"error authorizing query: %s not authorized to execute statement 'SHOW DATABASES', requires admin privilege"}`, user))
|
||||
|
|
Loading…
Reference in New Issue