mirror of
https://github.com/hanzoai/sqlite.git
synced 2026-10-30 18:22:26 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
//go:build !cgo || sqlite_purego
|
|
|
|
package sqlite
|
|
|
|
import (
|
|
"errors"
|
|
|
|
mod "modernc.org/sqlite"
|
|
lib "modernc.org/sqlite/lib"
|
|
)
|
|
|
|
// Reference constraint codes and the error unwrap for the pure-Go/modernc
|
|
// backend (same build condition as driver_nocgo.go / hooks_nocgo.go, including
|
|
// the sqlite_purego opt-out that forces modernc under cgo). The values come
|
|
// from modernc's generated lib package and are the same SQLite extended result
|
|
// codes mattn exposes under the CGO build.
|
|
var (
|
|
codeConstraintUnique = lib.SQLITE_CONSTRAINT_UNIQUE
|
|
codeConstraintPrimaryKey = lib.SQLITE_CONSTRAINT_PRIMARYKEY
|
|
codeConstraintForeignKey = lib.SQLITE_CONSTRAINT_FOREIGNKEY
|
|
|
|
// The PRIMARY code every constraint extended code reduces to (SQLITE_CONSTRAINT).
|
|
codeConstraint = lib.SQLITE_CONSTRAINT
|
|
)
|
|
|
|
// extendedCode extracts SQLite's extended result code from a modernc error.
|
|
// *sqlite.Error is a POINTER type with a Code() accessor that returns the
|
|
// extended code.
|
|
func extendedCode(err error) (int, bool) {
|
|
if e, ok := errors.AsType[*mod.Error](err); ok {
|
|
return e.Code(), true
|
|
}
|
|
return 0, false
|
|
}
|