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/instance.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/instance.go')
-rw-r--r-- | internal/db/bundb/instance.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/db/bundb/instance.go b/internal/db/bundb/instance.go index 09084642f..7f0e92634 100644 --- a/internal/db/bundb/instance.go +++ b/internal/db/bundb/instance.go @@ -34,7 +34,7 @@ import ( ) type instanceDB struct { - db *WrappedDB + db *DB state *state.State } @@ -56,7 +56,7 @@ func (i *instanceDB) CountInstanceUsers(ctx context.Context, domain string) (int count, err := q.Count(ctx) if err != nil { - return 0, i.db.ProcessError(err) + return 0, err } return count, nil } @@ -78,7 +78,7 @@ func (i *instanceDB) CountInstanceStatuses(ctx context.Context, domain string) ( count, err := q.Count(ctx) if err != nil { - return 0, i.db.ProcessError(err) + return 0, err } return count, nil } @@ -101,7 +101,7 @@ func (i *instanceDB) CountInstanceDomains(ctx context.Context, domain string) (i count, err := q.Count(ctx) if err != nil { - return 0, i.db.ProcessError(err) + return 0, err } return count, nil } @@ -148,7 +148,7 @@ func (i *instanceDB) getInstance(ctx context.Context, lookup string, dbQuery fun // Not cached! Perform database query. if err := dbQuery(&instance); err != nil { - return nil, i.db.ProcessError(err) + return nil, err } return &instance, nil @@ -211,7 +211,7 @@ func (i *instanceDB) PutInstance(ctx context.Context, instance *gtsmodel.Instanc return i.state.Caches.GTS.Instance().Store(instance, func() error { _, err := i.db.NewInsert().Model(instance).Exec(ctx) - return i.db.ProcessError(err) + return err }) } @@ -236,7 +236,7 @@ func (i *instanceDB) UpdateInstance(ctx context.Context, instance *gtsmodel.Inst Where("? = ?", bun.Ident("instance.id"), instance.ID). Column(columns...). Exec(ctx) - return i.db.ProcessError(err) + return err }) } @@ -256,7 +256,7 @@ func (i *instanceDB) GetInstancePeers(ctx context.Context, includeSuspended bool } if err := q.Scan(ctx, &instanceIDs); err != nil { - return nil, i.db.ProcessError(err) + return nil, err } if len(instanceIDs) == 0 { @@ -315,7 +315,7 @@ func (i *instanceDB) GetInstanceAccounts(ctx context.Context, domain string, max } if err := q.Scan(ctx, &accountIDs); err != nil { - return nil, i.db.ProcessError(err) + return nil, err } // Catch case of no accounts early. @@ -361,7 +361,7 @@ func (i *instanceDB) GetInstanceModeratorAddresses(ctx context.Context) ([]strin OrderExpr("? ASC", bun.Ident("user.email")) if err := q.Scan(ctx, &addresses); err != nil { - return nil, i.db.ProcessError(err) + return nil, err } if len(addresses) == 0 { |