summaryrefslogtreecommitdiff
path: root/internal/db/bundb/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/bundb/util.go')
-rw-r--r--internal/db/bundb/util.go55
1 files changed, 0 insertions, 55 deletions
diff --git a/internal/db/bundb/util.go b/internal/db/bundb/util.go
index faa80221f..9e1afb87e 100644
--- a/internal/db/bundb/util.go
+++ b/internal/db/bundb/util.go
@@ -19,64 +19,9 @@
package bundb
import (
- "context"
- "strings"
-
- "database/sql"
-
- "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/uptrace/bun"
)
-// processErrorResponse parses the given error and returns an appropriate DBError.
-func processErrorResponse(err error) db.Error {
- switch err {
- case nil:
- return nil
- case sql.ErrNoRows:
- return db.ErrNoEntries
- default:
- if strings.Contains(err.Error(), "duplicate key value violates unique constraint") {
- return db.ErrAlreadyExists
- }
- return err
- }
-}
-
-func exists(ctx context.Context, q *bun.SelectQuery) (bool, db.Error) {
- count, err := q.Count(ctx)
-
- exists := count != 0
-
- err = processErrorResponse(err)
-
- if err != nil {
- if err == db.ErrNoEntries {
- return false, nil
- }
- return false, err
- }
-
- return exists, nil
-}
-
-func notExists(ctx context.Context, q *bun.SelectQuery) (bool, db.Error) {
- count, err := q.Count(ctx)
-
- notExists := count == 0
-
- err = processErrorResponse(err)
-
- if err != nil {
- if err == db.ErrNoEntries {
- return true, nil
- }
- return false, err
- }
-
- return notExists, nil
-}
-
// whereEmptyOrNull is a convenience function to return a bun WhereGroup that specifies
// that the given column should be EITHER an empty string OR null.
//