Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Пешков Дмитрий committed Sep 23, 2024
1 parent 736760f commit 8907776
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/services/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
addUserQuery = "INSERT INTO users (id, login, password) VALUES ($1, $2, $3) ON CONFLICT(login) DO UPDATE SET login = EXCLUDED.login RETURNING id"
getUserByLoginQuery = "SELECT id, password FROM users WHERE login = $1"
updateBalanceByOrderQuery = "UPDATE users SET balance = balance + $1 WHERE id = (SELECT user_id FROM orders WHERE number = $2)"
updateBalanceByIdQuery = "UPDATE users SET balance = balance - $2 WHERE id = $1"
updateBalanceByIDQuery = "UPDATE users SET balance = balance - $2 WHERE id = $1"
)

type InputDataUser struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (w *WithdrawalService) Add(ctx context.Context, input InputWithdrawal) erro
if err != nil {
return err
}
_, err = tx.ExecContext(childCtx, updateBalanceByIdQuery, userID, input.Sum)
_, err = tx.ExecContext(childCtx, updateBalanceByIDQuery, userID, input.Sum)
if err != nil {
_ = tx.Rollback()
var pgError *pgconn.PgError
Expand Down

0 comments on commit 8907776

Please sign in to comment.