Skip to content

Commit

Permalink
fix: sqlite db path
Browse files Browse the repository at this point in the history
related to #110
  • Loading branch information
zema1 committed Nov 14, 2024
1 parent 8d63e75 commit 94f9a1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ctrl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (c *WatchVulnAppConfig) DBConnForEnt() (string, string, error) {
if u.RawQuery != "" {
query = u.RawQuery
}
return dialect.SQLite, fmt.Sprintf("file:%s?%s", u.Host, query), nil
return dialect.SQLite, fmt.Sprintf("file:%s%s?%s", u.Host, u.Path, query), nil
case dialect.MySQL:
path := ""
if u.Path != "" {
Expand Down
16 changes: 16 additions & 0 deletions ctrl/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ func TestWatchVulnAppConfig_DBConnForEnt(t *testing.T) {
assert.Equal("sqlite3", dialect)
assert.Equal("file:vuln_v3.db?cache=shared&_pragma=foreign_keys(1)", conn)

c = &WatchVulnAppConfig{
DBConn: "sqlite3:///tmp/vuln_v3.db",
}
dialect, conn, err = c.DBConnForEnt()
assert.Nil(err)
assert.Equal("sqlite3", dialect)
assert.Equal("file:/tmp/vuln_v3.db?cache=shared&_pragma=foreign_keys(1)", conn)

c = &WatchVulnAppConfig{
DBConn: "sqlite3://D:/vuln_v3.db",
}
dialect, conn, err = c.DBConnForEnt()
assert.Nil(err)
assert.Equal("sqlite3", dialect)
assert.Equal("file:D:/vuln_v3.db?cache=shared&_pragma=foreign_keys(1)", conn)

c = &WatchVulnAppConfig{
DBConn: "sqlite3://vuln_v3.sqlite3?cache=shared",
}
Expand Down

0 comments on commit 94f9a1b

Please sign in to comment.