Skip to content

Commit

Permalink
sql/sqlite: add libsql+file schema support (#2203)
Browse files Browse the repository at this point in the history
* Add libsql+file:// support
---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
Co-authored-by: Giau. Tran Minh <12751435+giautm@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 21, 2023
1 parent 0d57aa0 commit cfac114
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sql/sqlite/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ func init() {
sqlclient.DriverOpener(Open),
sqlclient.RegisterTxOpener(OpenTx),
sqlclient.RegisterCodec(MarshalHCL, EvalHCL),
sqlclient.RegisterFlavours("libsql+ws", "libsql+wss"),
sqlclient.RegisterFlavours("libsql+ws", "libsql+wss", "libsql+file"),
sqlclient.RegisterURLParser(sqlclient.URLParserFunc(func(u *url.URL) *sqlclient.URL {
return &sqlclient.URL{URL: u, DSN: strings.TrimPrefix(u.String(), "libsql+"), Schema: mainFile}
dsn := strings.TrimPrefix(u.String(), "libsql+")
if strings.HasPrefix(dsn, "file://") {
dsn = strings.Replace(dsn, "file://", "file:", 1)
}
return &sqlclient.URL{URL: u, DSN: dsn, Schema: mainFile}
})),
)
}
Expand Down

0 comments on commit cfac114

Please sign in to comment.