Skip to content

Commit

Permalink
fix: move db driver imports to db package
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Aug 25, 2023
1 parent a041c7a commit 72d4c3b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions cmd/soft/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"github.com/charmbracelet/soft-serve/server/version"
"github.com/spf13/cobra"
"go.uber.org/automaxprocs/maxprocs"

_ "modernc.org/sqlite" // sqlite driver
)

var (
Expand Down
1 change: 1 addition & 0 deletions server/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/charmbracelet/log"
"github.com/charmbracelet/soft-serve/server/config"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq" // postgres driver
_ "modernc.org/sqlite" // sqlite driver
)

Expand Down
8 changes: 4 additions & 4 deletions server/db/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/lib/pq"
sqlite "modernc.org/sqlite"
sqlite3 "modernc.org/sqlite/lib"
sqlitelib "modernc.org/sqlite/lib"
)

var (
Expand All @@ -28,9 +28,9 @@ func WrapError(err error) error {
// Handle sqlite constraint error.
if liteErr, ok := err.(*sqlite.Error); ok {
code := liteErr.Code()
if code == sqlite3.SQLITE_CONSTRAINT_PRIMARYKEY ||
code == sqlite3.SQLITE_CONSTRAINT_FOREIGNKEY ||
code == sqlite3.SQLITE_CONSTRAINT_UNIQUE {
if code == sqlitelib.SQLITE_CONSTRAINT_PRIMARYKEY ||
code == sqlitelib.SQLITE_CONSTRAINT_FOREIGNKEY ||
code == sqlitelib.SQLITE_CONSTRAINT_UNIQUE {
return ErrDuplicateKey
}
}
Expand Down

0 comments on commit 72d4c3b

Please sign in to comment.