Fall back to postgres when parsing the database connection string for a URI schema fails

This commit is contained in:
Neil Alexander 2020-01-09 16:56:29 +00:00
parent f7faf74528
commit feef9c124c
6 changed files with 18 additions and 12 deletions

View file

@ -16,7 +16,6 @@ package keydb
import (
"context"
"errors"
"net/url"
"github.com/matrix-org/dendrite/common/keydb/postgres"
@ -39,6 +38,8 @@ func NewDatabase(dataSourceName string) (Database, error) {
case "postgres":
return postgres.NewDatabase(dataSourceName)
default:
return nil, errors.New("unknown schema")
// if the scheme doesn't match, fall back to postgres in case the config has
// postgres key=value connection strings
return postgres.NewDatabase(dataSourceName)
}
}

View file

@ -16,7 +16,6 @@ package storage
import (
"context"
"errors"
"net/url"
"github.com/matrix-org/dendrite/common"
@ -40,6 +39,8 @@ func NewDatabase(dataSourceName string) (Database, error) {
case "postgres":
return postgres.NewDatabase(dataSourceName)
default:
return nil, errors.New("unknown schema")
// if the scheme doesn't match, fall back to postgres in case the config has
// postgres key=value connection strings
return postgres.NewDatabase(dataSourceName)
}
}

View file

@ -16,7 +16,6 @@ package storage
import (
"context"
"errors"
"net/url"
"github.com/matrix-org/dendrite/mediaapi/storage/postgres"
@ -42,6 +41,8 @@ func Open(dataSourceName string) (Database, error) {
case "postgres":
return postgres.Open(dataSourceName)
default:
return nil, errors.New("unknown schema")
// if the scheme doesn't match, fall back to postgres in case the config has
// postgres key=value connection strings
return postgres.Open(dataSourceName)
}
}

View file

@ -16,7 +16,6 @@ package storage
import (
"context"
"errors"
"net/url"
"github.com/matrix-org/dendrite/common"
@ -45,6 +44,8 @@ func NewPublicRoomsServerDatabase(dataSourceName string) (Database, error) {
case "postgres":
return postgres.NewPublicRoomsServerDatabase(dataSourceName)
default:
return nil, errors.New("unknown schema")
// if the scheme doesn't match, fall back to postgres in case the config has
// postgres key=value connection strings
return postgres.NewPublicRoomsServerDatabase(dataSourceName)
}
}

View file

@ -16,7 +16,6 @@ package storage
import (
"context"
"errors"
"net/url"
"github.com/matrix-org/dendrite/roomserver/api"
@ -67,6 +66,8 @@ func Open(dataSourceName string) (Database, error) {
case "postgres":
return postgres.Open(dataSourceName)
default:
return nil, errors.New("unknown schema")
// if the scheme doesn't match, fall back to postgres in case the config has
// postgres key=value connection strings
return postgres.Open(dataSourceName)
}
}

View file

@ -16,7 +16,6 @@ package storage
import (
"context"
"errors"
"net/url"
"time"
@ -58,6 +57,8 @@ func NewSyncServerDatasource(dataSourceName string) (Database, error) {
case "postgres":
return postgres.NewSyncServerDatasource(dataSourceName)
default:
return nil, errors.New("unknown schema")
// if the scheme doesn't match, fall back to postgres in case the config has
// postgres key=value connection strings
return postgres.NewSyncServerDatasource(dataSourceName)
}
}