Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(mongodb): support create mongodb database in tenant mode (#4830)

h3n4l53c76119c5d5
diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.go
index 4468f5e591..3074530df0 100644
--- a/backend/runner/taskrun/database_create_executor.go
+++ b/backend/runner/taskrun/database_create_executor.go
@@ -233,6 +233,10 @@ func getConnectionStatement(dbType db.Type, databaseName string) (string, error)
return fmt.Sprintf("USE DATABASE %s;\n", databaseName), nil
case db.SQLite:
return fmt.Sprintf("USE `%s`;\n", databaseName), nil
+ case db.MongoDB:
+ // We embed mongosh to execute the mongodb statement, and `use` statement is not effective in mongosh.
+ // We will connect to the specified database by specifying the database name in the connection string.
+ return "", nil
}
return "", errors.Errorf("unsupported database type %s", dbType)