Chore: Make cgo optional (for sqlite) (#108756)
* make cgo optional for sqlite * update go.mod; check error code differently * reduce api surface even more * move test errors into sqlite package * add a comment
This commit is contained in:
@@ -10,9 +10,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
"github.com/grafana/grafana/pkg/util/sqlite"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/lib/pq"
|
||||
"github.com/mattn/go-sqlite3"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
@@ -389,9 +389,8 @@ func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64,
|
||||
|
||||
// IsRowAlreadyExistsError checks if the error is the result of the row inserted already existing.
|
||||
func IsRowAlreadyExistsError(err error) bool {
|
||||
var sqlite sqlite3.Error
|
||||
if errors.As(err, &sqlite) {
|
||||
return sqlite.ExtendedCode == sqlite3.ErrConstraintUnique
|
||||
if sqlite.IsUniqueConstraintViolation(err) {
|
||||
return true
|
||||
}
|
||||
|
||||
var pg *pgconn.PgError
|
||||
|
||||
Reference in New Issue
Block a user