1 parent
bedcf4dd83
commit
d2a9033695
23 files changed
+1544
-6
No files matched your search
@@ -0,0 +1,17 @@
|
||||
//go:build cgo
|
||||
|
||||
package dberror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
// isSQLiteDuplicateKey 在启用CGO时识别SQLite驱动原因链;err为执行错误,返回是否唯一键或主键冲突。
|
||||
func isSQLiteDuplicateKey(err error) bool {
|
||||
var (
|
||||
sqliteError sqlite3.Error
|
||||
)
|
||||
return errors.As(err, &sqliteError) && (sqliteError.ExtendedCode == sqlite3.ErrConstraintUnique || sqliteError.ExtendedCode == sqlite3.ErrConstraintPrimaryKey)
|
||||
}
|
||||