Skip to content

Commit

Permalink
fix: v1.7 (#1418)
Browse files Browse the repository at this point in the history
* fix: setPieceMetadata sql

---------
Co-authored-by: Barry <[email protected]>
  • Loading branch information
constwz authored Jun 6, 2024
1 parent f420d9a commit d3a1707
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion store/sqldb/object_integrity.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func (s *SpDBImpl) DeleteReplicatePieceChecksum(objectID uint64, segmentIdx uint
metrics.SPDBTime.WithLabelValues(SPDBSuccessDelReplicatePieceChecksum).Observe(
time.Since(startTime).Seconds())
}()
err = s.db.Where("object_id = ? and segment_idx = ? and redundancy_index = ? ", objectID, segmentIdx, redundancyIdx).Delete(PieceHashTable{}).Error
err = s.db.Where("object_id = ? and segment_index = ? and redundancy_index = ? ", objectID, segmentIdx, redundancyIdx).Delete(PieceHashTable{}).Error
return err
}

Expand Down
6 changes: 3 additions & 3 deletions store/sqldb/object_integrity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func TestSpDBImpl_DeleteReplicatePieceChecksumSuccess(t *testing.T) {
)
s, mock := setupDB(t)
mock.ExpectBegin()
mock.ExpectExec("DELETE FROM `piece_hash` WHERE object_id = ? and segment_idx = ? and redundancy_index = ?").
mock.ExpectExec("DELETE FROM `piece_hash` WHERE object_id = ? and segment_index = ? and redundancy_index = ?").
WithArgs(objectID, segmentIdx, redundancyIdx).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectCommit()
err := s.DeleteReplicatePieceChecksum(objectID, segmentIdx, redundancyIdx)
Expand Down Expand Up @@ -546,7 +546,7 @@ func TestSpDBImpl_DeleteAllReplicatePieceChecksumSuccess(t *testing.T) {
)
s, mock := setupDB(t)
mock.ExpectBegin()
mock.ExpectExec("DELETE FROM `piece_hash` WHERE object_id = ? and segment_idx = ? and redundancy_index = ?").
mock.ExpectExec("DELETE FROM `piece_hash` WHERE object_id = ? and segment_index = ? and redundancy_index = ?").
WithArgs(objectID, segmentIdx, redundancyIdx).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectCommit()
err := s.DeleteAllReplicatePieceChecksum(objectID, redundancyIdx, pieceCount)
Expand All @@ -562,7 +562,7 @@ func TestSpDBImpl_DeleteAllReplicatePieceChecksumFailure(t *testing.T) {
)
s, mock := setupDB(t)
mock.ExpectBegin()
mock.ExpectExec("DELETE FROM `piece_hash` WHERE object_id = ? and segment_idx = ? and redundancy_index = ?").
mock.ExpectExec("DELETE FROM `piece_hash` WHERE object_id = ? and segment_index = ? and redundancy_index = ?").
WithArgs(objectID, segmentIdx, redundancyIdx).WillReturnError(mockDBInternalError)
mock.ExpectRollback()
mock.ExpectCommit()
Expand Down

0 comments on commit d3a1707

Please sign in to comment.