From 4a1a0863c4c93b6195a8d73233a6cac8b13a2bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Giba=C5=82a?= Date: Wed, 12 Jan 2022 13:23:56 +0100 Subject: [PATCH] Support 'postgresql' schema designator (#19275) --- config/database.go | 2 +- config/utils.go | 4 +++- config/utils_test.go | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config/database.go b/config/database.go index fdb82b038d..ff0d906395 100644 --- a/config/database.go +++ b/config/database.go @@ -153,7 +153,7 @@ func parseDSN(dsn string) (string, string, error) { // Strip off the mysql:// for the dsn with which to connect. dsn = s[1] - case "postgres": + case "postgres", "postgresql": // No changes required default: diff --git a/config/utils.go b/config/utils.go index cd8f05c1e4..3034db01ab 100644 --- a/config/utils.go +++ b/config/utils.go @@ -174,7 +174,9 @@ func Merge(cfg *model.Config, patch *model.Config, mergeConfig *utils.MergeConfi } func IsDatabaseDSN(dsn string) bool { - return strings.HasPrefix(dsn, "mysql://") || strings.HasPrefix(dsn, "postgres://") + return strings.HasPrefix(dsn, "mysql://") || + strings.HasPrefix(dsn, "postgres://") || + strings.HasPrefix(dsn, "postgresql://") } // stripPassword remove the password from a given DSN diff --git a/config/utils_test.go b/config/utils_test.go index 1754e174ac..4788fac807 100644 --- a/config/utils_test.go +++ b/config/utils_test.go @@ -159,10 +159,15 @@ func TestIsDatabaseDSN(t *testing.T) { Expected: true, }, { - Name: "Postgresql DSN", + Name: "Postgresql 'postgres' DSN", DSN: "postgres://localhost", Expected: true, }, + { + Name: "Postgresql 'postgresql' DSN", + DSN: "postgresql://localhost", + Expected: true, + }, { Name: "Empty DSN", DSN: "",