diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-01-09 17:03:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 17:03:36 +0000 |
commit | 714959126beca3a85bac0bd0e8be2e20e8cf8c84 (patch) | |
tree | acd5e0ebbaceff749fdbfe088a707fb6697b6974 /roomserver | |
parent | f7faf74528e1508f43d8d3705c6982b822bb3e9b (diff) |
Fall back to postgres when database connection string parsing fails (#842)
* Fall back to postgres when parsing the database connection string for a URI schema fails
* Fix behaviour so that it really tries postgres when URL parsing fails and it complains about unknown schema if it succeeds
Diffstat (limited to 'roomserver')
-rw-r--r-- | roomserver/storage/storage.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/roomserver/storage/storage.go b/roomserver/storage/storage.go index 325d96e9..62e8b64c 100644 --- a/roomserver/storage/storage.go +++ b/roomserver/storage/storage.go @@ -61,7 +61,9 @@ type Database interface { func Open(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.Open(dataSourceName) } switch uri.Scheme { case "postgres": |