Skip to content

Commit

Permalink
Fix #318 : Starts the db transaction after validating the data
Browse files Browse the repository at this point in the history
Signed-off-by: Kuntal Majumder <kuntal@infracloud.io>
  • Loading branch information
Kuntal Majumder committed Nov 18, 2020
1 parent 23c4fb0 commit 8c5dd2b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions db/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (

// CreateTemplate creates a new workflow template
func (d TinkDB) CreateTemplate(ctx context.Context, name string, data string, id uuid.UUID) error {
tx, err := d.instance.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable})
_, err := wflow.Parse([]byte(data))
if err != nil {
return errors.Wrap(err, "BEGIN transaction")
return err
}

_, err = wflow.Parse([]byte(data))
tx, err := d.instance.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable})
if err != nil {
return err
return errors.Wrap(err, "BEGIN transaction")
}

_, err = tx.Exec(`
Expand Down

0 comments on commit 8c5dd2b

Please sign in to comment.