Skip to content

Commit

Permalink
fix(payments): invalid sql query (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag authored Feb 21, 2023
1 parent 5d1fce9 commit 5f90073
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/app/models/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

type Transfer struct {
bun.BaseModel `bun:"payments.transfer"`
bun.BaseModel `bun:"payments.transfers"`

ID uuid.UUID `bun:",pk,nullzero"`
ConnectorID uuid.UUID `bun:",nullzero"`
Expand Down
13 changes: 10 additions & 3 deletions internal/app/storage/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package storage
import (
"context"

"github.com/jackc/pgx/v5"
"github.com/pkg/errors"

"github.com/uptrace/bun"

"github.com/jackc/pgx/v5"

"github.com/google/uuid"

"github.com/formancehq/payments/internal/app/models"
Expand Down Expand Up @@ -84,7 +83,11 @@ func (s *Storage) UpdateTransferStatus(ctx context.Context, transferID uuid.UUID
func (s *Storage) UpdateTransfersFromPayments(ctx context.Context, payments []*models.Payment) error {
var transfers []models.Transfer

paymentReferences := make([]string, 0, len(payments))
if len(payments) == 0 {
return nil
}

paymentReferences := make([]string, len(payments))
for paymentIdx := range payments {
paymentReferences[paymentIdx] = payments[paymentIdx].Reference
}
Expand All @@ -101,6 +104,10 @@ func (s *Storage) UpdateTransfersFromPayments(ctx context.Context, payments []*m
return e("failed to get transfer", err)
}

if len(transfers) == 0 {
return nil
}

for transferIdx := range transfers {
if transfers[transferIdx].Reference == nil {
continue
Expand Down

0 comments on commit 5f90073

Please sign in to comment.