fix errors on insertion to game, fix db creation of game
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/mattn/go-sqlite3"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
@@ -172,3 +173,14 @@ func DeleteAllSeq(db *sqlx.DB) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func IsErrUniqueConstraint(err error) {
|
||||
if sqliteErr, ok := err.(sqlite3.Error); ok {
|
||||
// SQLITE_CONSTRAINT_UNIQUE (extended code 2067)
|
||||
// or SQLITE_CONSTRAINT (basic code 19)
|
||||
if sqliteErr.ExtendedCode == sqlite3.ErrConstraintUnique ||
|
||||
sqliteErr.Code == sqlite3.ErrConstraint {
|
||||
fmt.Println("Record already exists")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user