Skip to content

Commit

Permalink
DiceDB#1115: handling integer parsing in SETBIT in certain situation (D…
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushal-003 authored Dec 1, 2024
1 parent e4444e3 commit ef85040
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions integration_tests/commands/http/append_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ func TestAPPEND(t *testing.T) {
{Command: "del", Body: map[string]interface{}{"key": "bitkey"}},
},
},
{
name: "SET and SETBIT commands followed by GET",
commands: []HTTPCommand{
{Command: "SET", Body: map[string]interface{}{"key": "key", "value": "10"}},
{Command: "SETBIT", Body: map[string]interface{}{"key": "key", "values": []string{"1", "1"}}},
{Command: "GET", Body: map[string]interface{}{"key": "key"}},
{Command: "SETBIT", Body: map[string]interface{}{"key": "key", "values": []string{"0", "1"}}},
},
expected: []interface{}{"OK", float64(0), "q0", float64(0)},
cleanup: []HTTPCommand{
{Command: "del", Body: map[string]interface{}{"key": "key"}},
},
},
{
name: "APPEND After SET and DEL",
commands: []HTTPCommand{
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/bytearray.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func ByteSliceToObj(store *dstore.Store, oldObj *object.Obj, b []byte, objType,
func ByteSliceToIntObj(store *dstore.Store, oldObj *object.Obj, b []byte) (*object.Obj, error) {
intVal, err := strconv.ParseInt(string(b), 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse byte slice to int: %v", err)
return store.NewObj(string(b), -1, object.ObjTypeString, object.ObjEncodingEmbStr), nil
}
return store.NewObj(intVal, -1, object.ObjTypeInt, object.ObjEncodingInt), nil
}
Expand Down

0 comments on commit ef85040

Please sign in to comment.