mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
fbsql disconnect from database with \c - (#2338)
* fbsql disconnect from database with `\c -` This adds the ability to disconnect from the current database by passing a hyphen to the `\c` meta-command. * Update cli/cli.go Co-authored-by: Matthew Jaffee <jaffee@pilosa.com> --------- Co-authored-by: Matthew Jaffee <jaffee@pilosa.com>
This commit is contained in:
parent
2f7ae30784
commit
10aab583c9
2 changed files with 14 additions and 1 deletions
|
|
@ -487,7 +487,12 @@ func (cmd *Command) connectToDatabase(dbName string) error {
|
|||
p = newNopPrinter()
|
||||
}
|
||||
|
||||
if dbName == "" {
|
||||
// Providing a blank ("") or hyphen ("-") dbName is the equivalent of
|
||||
// disconnecting from the current database. We support the hyphen option
|
||||
// because calling the `\c` meta-command without an argument is how you
|
||||
// print the current connection.
|
||||
switch dbName {
|
||||
case "-", "":
|
||||
cmd.databaseID = ""
|
||||
cmd.databaseName = ""
|
||||
p.Printf(cmd.connectionMessage())
|
||||
|
|
|
|||
8
cli/testdata/database
vendored
8
cli/testdata/database
vendored
|
|
@ -43,3 +43,11 @@ EXPECT:executing meta command: meta command 'connect' takes zero or one argument
|
|||
// Connect to a database.
|
||||
SEND:\c db1
|
||||
EXPECTCOMP:WithFormat:You are now connected to database "db1" ({uuid}).
|
||||
|
||||
// Disconnect from the current database.
|
||||
SEND:\c -
|
||||
EXPECT:You are not connected to a database.
|
||||
|
||||
// Connect to a database again.
|
||||
SEND:\c db1
|
||||
EXPECTCOMP:WithFormat:You are now connected to database "db1" ({uuid}).
|
||||
Loading…
Add table
Reference in a new issue