diff --git a/internal/database/dialect/mariadb.go b/internal/database/dialect/mariadb.go index 2063f445..a3be1494 100644 --- a/internal/database/dialect/mariadb.go +++ b/internal/database/dialect/mariadb.go @@ -73,7 +73,7 @@ func (db MariaDB) PasswordEnvNames(c config.Global) []string { func (MariaDB) ExecCommand(conf config.Exec) *command.Builder { cmd := command.NewBuilder( command.NewEnv("MYSQL_PWD", conf.Password), - "mysql", "--host="+conf.Host, "--user="+conf.Username, + "exec", "mysql", "--host="+conf.Host, "--user="+conf.Username, ) if conf.Database != "" { cmd.Push("--database=" + conf.Database) diff --git a/internal/database/dialect/mariadb_test.go b/internal/database/dialect/mariadb_test.go index d0704909..b046eb47 100644 --- a/internal/database/dialect/mariadb_test.go +++ b/internal/database/dialect/mariadb_test.go @@ -147,17 +147,17 @@ func TestMariaDB_ExecCommand(t *testing.T) { { "default", args{config.Exec{Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u"}}}, - command.NewBuilder(command.Env{Key: "MYSQL_PWD"}, "mysql", "--host=1.1.1.1", "--user=u", "--database=d"), + command.NewBuilder(command.Env{Key: "MYSQL_PWD"}, "exec", "mysql", "--host=1.1.1.1", "--user=u", "--database=d"), }, { "disable-headers", args{config.Exec{DisableHeaders: true, Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u"}}}, - command.NewBuilder(command.Env{Key: "MYSQL_PWD"}, "mysql", "--host=1.1.1.1", "--user=u", "--database=d", "--skip-column-names"), + command.NewBuilder(command.Env{Key: "MYSQL_PWD"}, "exec", "mysql", "--host=1.1.1.1", "--user=u", "--database=d", "--skip-column-names"), }, { "command", args{config.Exec{Command: "show databases", Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u"}}}, - command.NewBuilder(command.Env{Key: "MYSQL_PWD"}, "mysql", "--host=1.1.1.1", "--user=u", "--database=d", "--execute=show databases"), + command.NewBuilder(command.Env{Key: "MYSQL_PWD"}, "exec", "mysql", "--host=1.1.1.1", "--user=u", "--database=d", "--execute=show databases"), }, } for _, tt := range tests { diff --git a/internal/database/dialect/mongodb.go b/internal/database/dialect/mongodb.go index 0091dafc..726f3273 100644 --- a/internal/database/dialect/mongodb.go +++ b/internal/database/dialect/mongodb.go @@ -79,7 +79,7 @@ func (db MongoDB) AuthenticationDatabase(c config.Global) string { func (db MongoDB) ExecCommand(conf config.Exec) *command.Builder { cmd := command.NewBuilder( - command.Raw(`"$(which mongosh || which mongo)"`), + "exec", command.Raw(`"$(which mongosh || which mongo)"`), "--host="+conf.Host, "--username="+conf.Username, "--password="+conf.Password, diff --git a/internal/database/dialect/mongodb_test.go b/internal/database/dialect/mongodb_test.go index 861b7b70..a8074df2 100644 --- a/internal/database/dialect/mongodb_test.go +++ b/internal/database/dialect/mongodb_test.go @@ -152,17 +152,17 @@ func TestMongoDB_ExecCommand(t *testing.T) { { "default", args{config.Exec{Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u", Password: "p"}}}, - command.NewBuilder(command.Raw(`"$(which mongosh || which mongo)"`), "--host=1.1.1.1", "--username=u", "--password=p", "--authenticationDatabase=d", "d"), + command.NewBuilder("exec", command.Raw(`"$(which mongosh || which mongo)"`), "--host=1.1.1.1", "--username=u", "--password=p", "--authenticationDatabase=d", "d"), }, { "disable-headers", args{config.Exec{DisableHeaders: true, Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u", Password: "p"}}}, - command.NewBuilder(command.Raw(`"$(which mongosh || which mongo)"`), "--host=1.1.1.1", "--username=u", "--password=p", "--authenticationDatabase=d", "--quiet", "d"), + command.NewBuilder("exec", command.Raw(`"$(which mongosh || which mongo)"`), "--host=1.1.1.1", "--username=u", "--password=p", "--authenticationDatabase=d", "--quiet", "d"), }, { "command", args{config.Exec{Command: "show databases", Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u", Password: "p"}}}, - command.NewBuilder(command.Raw(`"$(which mongosh || which mongo)"`), "--host=1.1.1.1", "--username=u", "--password=p", "--authenticationDatabase=d", "--eval=show databases", "d"), + command.NewBuilder("exec", command.Raw(`"$(which mongosh || which mongo)"`), "--host=1.1.1.1", "--username=u", "--password=p", "--authenticationDatabase=d", "--eval=show databases", "d"), }, } for _, tt := range tests { diff --git a/internal/database/dialect/postgres.go b/internal/database/dialect/postgres.go index b8ffbb20..11fea89a 100644 --- a/internal/database/dialect/postgres.go +++ b/internal/database/dialect/postgres.go @@ -116,7 +116,7 @@ func (db Postgres) PasswordEnvNames(c config.Global) []string { func (Postgres) ExecCommand(conf config.Exec) *command.Builder { cmd := command.NewBuilder( command.NewEnv("PGPASSWORD", conf.Password), - "psql", "--host="+conf.Host, "--username="+conf.Username, + "exec", "psql", "--host="+conf.Host, "--username="+conf.Username, ) if conf.Database != "" { cmd.Push("--dbname=" + conf.Database) diff --git a/internal/database/dialect/postgres_test.go b/internal/database/dialect/postgres_test.go index 4e340524..e355ec97 100644 --- a/internal/database/dialect/postgres_test.go +++ b/internal/database/dialect/postgres_test.go @@ -168,17 +168,17 @@ func TestPostgres_ExecCommand(t *testing.T) { { "default", args{config.Exec{Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u"}}}, - command.NewBuilder(command.NewEnv("PGPASSWORD", ""), "psql", "--host=1.1.1.1", "--username=u", "--dbname=d"), + command.NewBuilder(command.NewEnv("PGPASSWORD", ""), "exec", "psql", "--host=1.1.1.1", "--username=u", "--dbname=d"), }, { "disable-headers", args{config.Exec{DisableHeaders: true, Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u"}}}, - command.NewBuilder(command.NewEnv("PGPASSWORD", ""), "psql", "--host=1.1.1.1", "--username=u", "--dbname=d", "--tuples-only"), + command.NewBuilder(command.NewEnv("PGPASSWORD", ""), "exec", "psql", "--host=1.1.1.1", "--username=u", "--dbname=d", "--tuples-only"), }, { "command", args{config.Exec{Command: "select true", Global: config.Global{Host: "1.1.1.1", Database: "d", Username: "u"}}}, - command.NewBuilder(command.NewEnv("PGPASSWORD", ""), "psql", "--host=1.1.1.1", "--username=u", "--dbname=d", "--command=select true"), + command.NewBuilder(command.NewEnv("PGPASSWORD", ""), "exec", "psql", "--host=1.1.1.1", "--username=u", "--dbname=d", "--command=select true"), }, } for _, tt := range tests {