Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions drivers/completer/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ func (c completer) complete(previousWords []string, text []rune) [][]rune {
}
/* XXX: implement tab completion for DELETE ... USING */

/* Complete CREATE */
if tailMatches(IGNORE_CASE, previousWords, "CREATE") {
return completeFromList(text, "DATABASE", "SEQUENCE", "TABLE", "VIEW", "TEMPORARY")
}
if tailMatches(IGNORE_CASE, previousWords, "CREATE", "TEMP|TEMPORARY") {
return completeFromList(text, "TABLE", "VIEW")
}
if tailMatches(IGNORE_CASE, previousWords, "CREATE", "TABLE", "*") || tailMatches(IGNORE_CASE, previousWords, "CREATE", "TEMP|TEMPORARY", "TABLE", "*") {
return completeFromList(text, "(")
}
/* INSERT --- can be inside EXPLAIN, RULE, etc */
/* Complete INSERT with "INTO" */
if tailMatches(IGNORE_CASE, previousWords, "INSERT") {
Expand Down
22 changes: 22 additions & 0 deletions drivers/completer/completer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,28 @@ func TestCompleter(t *testing.T) {
[]string{},
2,
},
{
"type on create",
"CREATE ",
7,
[]string{
"DATABASE",
"TABLE",
"SEQUENCE",
"VIEW",
"TEMPORARY",
},
0,
},
{
"brackets on create table",
"CREATE TABLE p ",
15,
[]string{
"(",
},
0,
},
}

completer := NewDefaultCompleter(WithReader(mockReader{}), WithConnStrings([]string{"pg://"}))
Expand Down