Skip to content

Commit

Permalink
Merge branch 'deploy' of github.com:go-park-mail-ru/2023_2_Hamster in…
Browse files Browse the repository at this point in the history
…to deploy
  • Loading branch information
CodeMaster482 committed Nov 13, 2023
2 parents a23e637 + 8b0ba7c commit 50d3b91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"errors"
"fmt"

"github.com/jackc/pgx/v4"

"github.com/go-park-mail-ru/2023_2_Hamster/cmd/api/init/db/postgresql"
"github.com/go-park-mail-ru/2023_2_Hamster/internal/common/logger"
"github.com/go-park-mail-ru/2023_2_Hamster/internal/models"
"github.com/google/uuid"
"github.com/jackc/pgx/v4"
)

const (
Expand Down Expand Up @@ -89,6 +90,7 @@ func (r *Repository) UpdateTag(ctx context.Context, tag *models.Category) error
} else if err != nil {
return fmt.Errorf("[repo] failed request db %s, %w", CategoryGet, err)
} */

var err error
if tag.ParentID == uuid.Nil {
_, err = r.db.Exec(ctx, CategoryUpdate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ func (r *transactionRep) CreateTransaction(ctx context.Context, transaction *mod
return uuid.Nil, fmt.Errorf("failed to start transaction: %w", err)
}
defer func() {
if err := tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
if err != nil {
if err = tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
}

}
}()

Expand Down Expand Up @@ -201,9 +204,13 @@ func (r *transactionRep) UpdateTransaction(ctx context.Context, transaction *mod
if err != nil {
return fmt.Errorf("[repo] failed to start transaction: %w", err)
}

defer func() {
if err := tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
if err != nil {
if err = tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
}

}
}()

Expand Down Expand Up @@ -295,9 +302,13 @@ func (r *transactionRep) DeleteTransaction(ctx context.Context, transactionID uu
if err != nil {
return fmt.Errorf("[repo] failed to start transaction: %w", err)
}

defer func() {
if err := tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
if err != nil {
if err = tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
}

}
}()

Expand Down

0 comments on commit 50d3b91

Please sign in to comment.