diff options
author | 2023-08-17 17:26:21 +0100 | |
---|---|---|
committer | 2023-08-17 17:26:21 +0100 | |
commit | d5d6ad406f47ae738a7f6b1699b3b6e7ef916bb9 (patch) | |
tree | 44df2eaf48eca66023023569d4ba8d901d800226 /internal/db/bundb/user.go | |
parent | [chore]: Bump github.com/jackc/pgx/v5 from 5.4.2 to 5.4.3 (#2112) (diff) | |
download | gotosocial-d5d6ad406f47ae738a7f6b1699b3b6e7ef916bb9.tar.xz |
[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 <grufwub@gmail.com>
Co-authored-by: Daenney <daenney@users.noreply.github.com>
Diffstat (limited to 'internal/db/bundb/user.go')
-rw-r--r-- | internal/db/bundb/user.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/db/bundb/user.go b/internal/db/bundb/user.go index 9df05596e..eaa1d8e3d 100644 --- a/internal/db/bundb/user.go +++ b/internal/db/bundb/user.go @@ -31,7 +31,7 @@ import ( ) type userDB struct { - db *WrappedDB + db *DB state *state.State } @@ -121,7 +121,7 @@ func (u *userDB) getUser(ctx context.Context, lookup string, dbQuery func(*gtsmo // Not cached! perform database query. if err := dbQuery(&user); err != nil { - return nil, u.db.ProcessError(err) + return nil, err } return &user, nil @@ -150,7 +150,7 @@ func (u *userDB) GetAllUsers(ctx context.Context) ([]*gtsmodel.User, error) { Table("users"). Column("id"). Scan(ctx, &userIDs); err != nil { - return nil, u.db.ProcessError(err) + return nil, err } // Transform user IDs into user slice. @@ -163,7 +163,7 @@ func (u *userDB) PutUser(ctx context.Context, user *gtsmodel.User) error { NewInsert(). Model(user). Exec(ctx) - return u.db.ProcessError(err) + return err }) } @@ -183,7 +183,7 @@ func (u *userDB) UpdateUser(ctx context.Context, user *gtsmodel.User, columns .. Where("? = ?", bun.Ident("user.id"), user.ID). Column(columns...). Exec(ctx) - return u.db.ProcessError(err) + return err }) } @@ -207,5 +207,5 @@ func (u *userDB) DeleteUserByID(ctx context.Context, userID string) error { TableExpr("? AS ?", bun.Ident("users"), bun.Ident("user")). Where("? = ?", bun.Ident("user.id"), userID). Exec(ctx) - return u.db.ProcessError(err) + return err } |