Support 'postgresql' schema designator (#19275)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
664af506a3
Коммит
4a1a0863c4
@@ -153,7 +153,7 @@ func parseDSN(dsn string) (string, string, error) {
|
|||||||
// Strip off the mysql:// for the dsn with which to connect.
|
// Strip off the mysql:// for the dsn with which to connect.
|
||||||
dsn = s[1]
|
dsn = s[1]
|
||||||
|
|
||||||
case "postgres":
|
case "postgres", "postgresql":
|
||||||
// No changes required
|
// No changes required
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -174,7 +174,9 @@ func Merge(cfg *model.Config, patch *model.Config, mergeConfig *utils.MergeConfi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsDatabaseDSN(dsn string) bool {
|
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
|
// stripPassword remove the password from a given DSN
|
||||||
|
|||||||
@@ -159,10 +159,15 @@ func TestIsDatabaseDSN(t *testing.T) {
|
|||||||
Expected: true,
|
Expected: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Postgresql DSN",
|
Name: "Postgresql 'postgres' DSN",
|
||||||
DSN: "postgres://localhost",
|
DSN: "postgres://localhost",
|
||||||
Expected: true,
|
Expected: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "Postgresql 'postgresql' DSN",
|
||||||
|
DSN: "postgresql://localhost",
|
||||||
|
Expected: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "Empty DSN",
|
Name: "Empty DSN",
|
||||||
DSN: "",
|
DSN: "",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user