@@ -3,10 +3,12 @@ package sqlite
33import (
44 "context"
55
6- "github.com/mattn/go-sqlite3"
6+ "github.com/pkg/errors"
7+ "modernc.org/sqlite"
8+ sqlite3 "modernc.org/sqlite/lib"
9+
710 "github.com/oom-ai/oomstore/internal/database/dbutil"
811 "github.com/oom-ai/oomstore/internal/database/metadata"
9- "github.com/pkg/errors"
1012)
1113
1214func createRevision (ctx context.Context , sqlxCtx metadata.SqlxContext , opt metadata.CreateRevisionOpt ) (int , string , error ) {
@@ -21,8 +23,8 @@ func createRevision(ctx context.Context, sqlxCtx metadata.SqlxContext, opt metad
2123 insertQuery := "INSERT INTO feature_group_revision(group_id, revision, snapshot_table, cdc_table, anchored, description) VALUES (?, ?, ?, ?, ?, ?)"
2224 res , err := sqlxCtx .ExecContext (ctx , sqlxCtx .Rebind (insertQuery ), opt .GroupID , opt .Revision , snapshotTable , cdcTable , opt .Anchored , opt .Description )
2325 if err != nil {
24- if sqliteErr , ok := err .(sqlite3 .Error ); ok {
25- if sqliteErr .ExtendedCode == sqlite3 .ErrConstraintUnique {
26+ if sqliteErr , ok := err .(* sqlite .Error ); ok {
27+ if sqliteErr .Code () == sqlite3 .SQLITE_CONSTRAINT_UNIQUE {
2628 return 0 , "" , errors .Errorf ("revision already exists: groupID=%d, revision=%d" , opt .GroupID , opt .Revision )
2729 }
2830 }
0 commit comments