Fixed missing errors (#694)

This commit is contained in:
Harshil Sharma 2021-07-09 09:11:54 +05:30 committed by GitHub
parent ebd477464b
commit e0ccfb90e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View file

@ -427,7 +427,10 @@ func (s *SQLStore) InsertBlock(c store.Container, block *model.Block, userID str
query := insertQuery.SetMap(insertQueryValues)
_, err = sq.ExecContextWith(ctx, tx, query.Into(s.tablePrefix+"blocks"))
if err != nil {
tx.Rollback()
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr))
}
return err
}
}
@ -437,7 +440,9 @@ func (s *SQLStore) InsertBlock(c store.Container, block *model.Block, userID str
_, err = sq.ExecContextWith(ctx, tx, query.Into(s.tablePrefix+"blocks_history"))
if err != nil {
_ = tx.Rollback()
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr))
}
return err
}
@ -475,7 +480,9 @@ func (s *SQLStore) DeleteBlock(c store.Container, blockID string, modifiedBy str
_, err = sq.ExecContextWith(ctx, tx, insertQuery)
if err != nil {
_ = tx.Rollback()
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr))
}
return err
}
@ -486,7 +493,9 @@ func (s *SQLStore) DeleteBlock(c store.Container, blockID string, modifiedBy str
_, err = sq.ExecContextWith(ctx, tx, deleteQuery)
if err != nil {
_ = tx.Rollback()
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr))
}
return err
}
@ -558,6 +567,9 @@ func (s *SQLStore) GetBlock(c store.Container, blockID string) (*model.Block, er
}
blocks, err := s.blocksFromRows(rows)
if err != nil {
return nil, err
}
if len(blocks) == 0 {
return nil, nil

View file

@ -9,8 +9,8 @@ import (
)
func InsertBlocks(t *testing.T, s store.Store, container store.Container, blocks []model.Block, userID string) {
for _, block := range blocks {
err := s.InsertBlock(container, &block, userID)
for i := range blocks {
err := s.InsertBlock(container, &blocks[i], userID)
require.NoError(t, err)
}
}