From d5d6ad406f47ae738a7f6b1699b3b6e7ef916bb9 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:26:21 +0100 Subject: [bugfix] fix double firing bun.DB query hooks (#2124) * improve bun.DB wrapping readability + comments, fix double-firing query hooks * fix incorrect code comment placement * fix linter issues * Update internal/db/basic.go * do as the linter commmands ... --------- Signed-off-by: kim Co-authored-by: Daenney --- internal/db/bundb/errors.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal/db/bundb/errors.go') diff --git a/internal/db/bundb/errors.go b/internal/db/bundb/errors.go index 6bec8edae..46735ca80 100644 --- a/internal/db/bundb/errors.go +++ b/internal/db/bundb/errors.go @@ -32,6 +32,11 @@ var errBusy = errors.New("busy") // processPostgresError processes an error, replacing any postgres specific errors with our own error type func processPostgresError(err error) error { + // Catch nil errs. + if err == nil { + return nil + } + // Attempt to cast as postgres pgErr, ok := err.(*pgconn.PgError) if !ok { @@ -50,6 +55,11 @@ func processPostgresError(err error) error { // processSQLiteError processes an error, replacing any sqlite specific errors with our own error type func processSQLiteError(err error) error { + // Catch nil errs. + if err == nil { + return nil + } + // Attempt to cast as sqlite sqliteErr, ok := err.(*sqlite.Error) if !ok { -- cgit v1.2.3