Add ParseFileURI and use it when dealing with file URIs (#1088)

* Add ParseFileURI and use it when dealing with file URIs

Fixes #1059

* Missing file

* Linting
This commit is contained in:
Kegsay 2020-06-04 11:18:08 +01:00 committed by GitHub
parent d4f9a4bb97
commit e7d1ac84c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 66 additions and 51 deletions

View file

@ -37,7 +37,11 @@ type Database struct {
func NewDatabase(dataSourceName string) (*Database, error) {
var result Database
var err error
if result.db, err = sqlutil.Open(internal.SQLiteDriverName(), dataSourceName, nil); err != nil {
cs, err := sqlutil.ParseFileURI(dataSourceName)
if err != nil {
return nil, err
}
if result.db, err = sqlutil.Open(internal.SQLiteDriverName(), cs, nil); err != nil {
return nil, err
}
if err = result.prepare(); err != nil {

View file

@ -34,7 +34,7 @@ func NewDatabase(
case "postgres":
return nil, fmt.Errorf("Cannot use postgres implementation")
case "file":
return sqlite3.NewDatabase(uri.Path)
return sqlite3.NewDatabase(dataSourceName)
default:
return nil, fmt.Errorf("Cannot use postgres implementation")
}