Support 'postgresql' schema designator (#19275)

Этот коммит содержится в:
Szymon Gibała
2022-01-12 13:23:56 +01:00
коммит произвёл GitHub
родитель 664af506a3
Коммит 4a1a0863c4
3 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@@ -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:

Просмотреть файл

@@ -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

Просмотреть файл

@@ -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: "",