mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-01-31 08:04:28 -06:00
Revert "Also check sqlite for constraint error"
This reverts commit 7d310514
This commit is contained in:
parent
7d31051487
commit
908edd304d
|
@ -16,22 +16,10 @@
|
||||||
|
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import "github.com/lib/pq"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/lib/pq"
|
// IsUniqueConstraintViolationErr returns true if the error is a postgresql unique_violation error
|
||||||
"github.com/mattn/go-sqlite3"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsUniqueConstraintViolationErr returns true if the error is a postgresql unique_violation or sqlite3.ErrConstraint
|
|
||||||
func IsUniqueConstraintViolationErr(err error) bool {
|
func IsUniqueConstraintViolationErr(err error) bool {
|
||||||
pqErr, ok := err.(*pq.Error)
|
pqErr, ok := err.(*pq.Error)
|
||||||
if ok {
|
return ok && pqErr.Code == "23505"
|
||||||
return pqErr.Code == "23505"
|
|
||||||
}
|
|
||||||
sqliteErr, ok := err.(*sqlite3.Error)
|
|
||||||
if ok {
|
|
||||||
return errors.Is(sqliteErr, sqlite3.ErrConstraint)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue