From 95f1c94bf5a271a99e4d76635cd387e9855917fb Mon Sep 17 00:00:00 2001 From: David Terry Date: Wed, 10 Oct 2018 14:03:37 +0300 Subject: [PATCH] vat.fold: check for errors in insert before updating checked_headers --- pkg/transformers/vat_fold/repository.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/transformers/vat_fold/repository.go b/pkg/transformers/vat_fold/repository.go index 6f81bce9..f89b8057 100644 --- a/pkg/transformers/vat_fold/repository.go +++ b/pkg/transformers/vat_fold/repository.go @@ -46,6 +46,10 @@ func (repository VatFoldRepository) Create(headerID int64, models []VatFoldModel VALUES($1, $2, $3, $4::NUMERIC, $5, $6)`, headerID, model.Ilk, model.Urn, model.Rate, model.TransactionIndex, model.Raw, ) + if err != nil { + tx.Rollback() + return err + } _, err = tx.Exec( `INSERT INTO public.checked_headers (header_id, vat_fold_checked) VALUES($1, $2)