Skip to content

Commit

Permalink
Merge pull request #24 from gobicycle/develop
Browse files Browse the repository at this point in the history
db err check
  • Loading branch information
gobicycle authored Oct 9, 2024
2 parents 9138f5f + 6027eac commit c9fb035
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
37 changes: 36 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ func (c *Connection) GetTonWalletsAddresses(
}
res = append(res, a)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down Expand Up @@ -258,6 +261,9 @@ func (c *Connection) GetJettonOwnersAddresses(
}
res = append(res, ow)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand All @@ -284,7 +290,9 @@ func (c *Connection) LoadAddressBook(ctx context.Context) error {
}
res[addr] = core.AddressInfo{Type: t, Owner: nil, UserID: userID}
}

if rows.Err() != nil {
return rows.Err()
}
rows, err = c.client.Query(ctx, `
SELECT jw.address, jw.type, tw.address, jw.user_id
FROM payments.jetton_wallets jw
Expand All @@ -302,6 +310,9 @@ func (c *Connection) LoadAddressBook(ctx context.Context) error {
}
res[addr] = core.AddressInfo{Type: t, Owner: &owner, UserID: userID}
}
if rows.Err() != nil {
return rows.Err()
}

c.addressBook.addresses = res
log.Info("Address book loaded")
Expand Down Expand Up @@ -491,6 +502,9 @@ func (c *Connection) GetExternalWithdrawalTasks(ctx context.Context, limit int)
}
res = append(res, w)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down Expand Up @@ -520,6 +534,9 @@ func (c *Connection) GetServiceHotWithdrawalTasks(ctx context.Context, limit int
}
tasks = append(tasks, w)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -550,6 +567,9 @@ func (c *Connection) GetServiceDepositWithdrawalTasks(ctx context.Context, limit
}
tasks = append(tasks, w)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -729,6 +749,9 @@ func (c *Connection) GetTonInternalWithdrawalTasks(ctx context.Context, limit in
task.Currency = core.TonSymbol
tasks = append(tasks, task)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -776,6 +799,9 @@ func (c *Connection) GetJettonInternalWithdrawalTasks(
}
tasks = append(tasks, task)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return tasks, nil
}

Expand Down Expand Up @@ -997,6 +1023,9 @@ func (c *Connection) SetExpired(ctx context.Context) error {
}
ids = append(ids, queryID)
}
if rows.Err() != nil {
return rows.Err()
}

for _, id := range ids {
_, err = tx.Exec(ctx, `
Expand Down Expand Up @@ -1164,6 +1193,9 @@ func (c *Connection) GetIncome(
}
res = append(res, deposit)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down Expand Up @@ -1231,6 +1263,9 @@ func (c *Connection) GetIncomeHistory(
income.Utime = uint32(t.Unix())
res = append(res, income)
}
if rows.Err() != nil {
return nil, rows.Err()
}
return res, nil
}

Expand Down
6 changes: 6 additions & 0 deletions db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func Test_SetExpired(t *testing.T) {
extRes[i] = r
i++
}
if rows.Err() != nil {
t.Fatal("rows err: ", rows.Err())
}
if externalResult != extRes {
t.Fatalf("invalid external result pattern: %v", extRes)
}
Expand All @@ -246,6 +249,9 @@ func Test_SetExpired(t *testing.T) {
intRes[i] = r
i++
}
if rows.Err() != nil {
t.Fatal("rows err: ", rows.Err())
}
if internalResult != intRes {
t.Fatalf("invalid internal result pattern: %v", intRes)
}
Expand Down

0 comments on commit c9fb035

Please sign in to comment.