Skip to content

Commit

Permalink
Merge pull request #6415 from dolthub/macneale4/sql-client-user
Browse files Browse the repository at this point in the history
Allow sql-client to get the username from the config file
  • Loading branch information
macneale4 authored Jul 28, 2023
2 parents 30d548e + 42baaa8 commit c0ab3fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 6 additions & 5 deletions go/cmd/dolt/commands/sqlserver/sqlclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []stri
var serverController *ServerController
var err error

if _, ok := apr.GetValue(commands.UserFlag); !ok {
cli.PrintErrln(color.RedString("--user or -u argument is required"))
return 1
}

if apr.Contains(sqlClientDualFlag) {
if !dEnv.Valid() {
if !cli.CheckEnvIsValid(dEnv) {
Expand Down Expand Up @@ -212,6 +207,12 @@ func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []stri
cli.PrintErrln(err.Error())
return 1
}

if parsedMySQLConfig.User == "" {
cli.PrintErrln(color.RedString("--user or -u argument is required"))
return 1
}

parsedMySQLConfig.DBName = dbToUse
mysqlConnector, err := mysqlDriver.NewConnector(parsedMySQLConfig)
if err != nil {
Expand Down
6 changes: 0 additions & 6 deletions integration-tests/bats/sql-client.bats
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ teardown() {
[ "${lines[8]}" = '+-----------------+' ]
}

@test "sql-client: --user argument is required" {
run dolt sql-client
[ "$status" -eq 1 ]
[[ "$output" =~ "--user or -u argument is required" ]] || false
}

@test "sql-client: multiple statments in --query" {
cd repo1
start_sql_server repo1
Expand Down

0 comments on commit c0ab3fc

Please sign in to comment.