(core) Update golang dependencies
`` go get -u ./... go mod tidy ``` Fixed SQLite related code to fit latest changes in SQLite driver
This commit is contained in:
51
base/database/storage/sqlite/dberrors/bob_errors.bob.go
Normal file
51
base/database/storage/sqlite/dberrors/bob_errors.bob.go
Normal file
@@ -0,0 +1,51 @@
|
||||
// Code generated by BobGen sqlite v0.41.1. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
sqliteDriver "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
// ErrUniqueConstraint captures all unique constraint errors by explicitly leaving `s` empty.
|
||||
var ErrUniqueConstraint = &UniqueConstraintError{s: ""}
|
||||
|
||||
type UniqueConstraintError struct {
|
||||
// schema is the schema where the unique constraint is defined.
|
||||
schema string
|
||||
// table is the name of the table where the unique constraint is defined.
|
||||
table string
|
||||
// columns are the columns constituting the unique constraint.
|
||||
columns []string
|
||||
// s is a string uniquely identifying the constraint in the raw error message returned from the database.
|
||||
s string
|
||||
}
|
||||
|
||||
func (e *UniqueConstraintError) Error() string {
|
||||
return e.s
|
||||
}
|
||||
|
||||
func (e *UniqueConstraintError) Is(target error) bool {
|
||||
var err *sqliteDriver.Error
|
||||
if !errors.As(target, &err) {
|
||||
return false
|
||||
}
|
||||
|
||||
// 1555 is for Primary Key Constraint
|
||||
// 2067 is for Unique Constraint
|
||||
if err.Code() != 1555 && err.Code() != 2067 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, col := range e.columns {
|
||||
if !strings.Contains(err.Error(), fmt.Sprintf("%s.%s", e.table, col)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated by BobGen sqlite v0.41.1. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
import "github.com/stephenafamo/bob"
|
||||
|
||||
// Set the testDB to enable tests that use the database
|
||||
var testDB bob.Transactor[bob.Tx]
|
||||
17
base/database/storage/sqlite/dberrors/records.bob.go
Normal file
17
base/database/storage/sqlite/dberrors/records.bob.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// Code generated by BobGen sqlite v0.41.1. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
var RecordErrors = &recordErrors{
|
||||
ErrUniquePkMainRecords: &UniqueConstraintError{
|
||||
schema: "",
|
||||
table: "records",
|
||||
columns: []string{"key"},
|
||||
s: "pk_main_records",
|
||||
},
|
||||
}
|
||||
|
||||
type recordErrors struct {
|
||||
ErrUniquePkMainRecords *UniqueConstraintError
|
||||
}
|
||||
Reference in New Issue
Block a user