diff --git a/internal/server/crud.go b/internal/server/crud.go index b43c7d51..c8a9a624 100644 --- a/internal/server/crud.go +++ b/internal/server/crud.go @@ -746,16 +746,11 @@ func (s *Server) cmdSET(msg *Message) (resp.Value, commandDetails, error) { } var flist field.List - if len(fields) > 0 { - old := col.Get(id) - if old != nil { - flist = old.Fields() - } - for _, f := range fields { - flist = flist.Set(f) - } - } else { - flist = field.MakeList(fields) + if old := col.Get(id); old != nil { + flist = old.Fields() + } + for _, f := range fields { + flist = flist.Set(f) } obj := object.New(id, oobj, ex, flist) old := col.Set(obj) diff --git a/tests/keys_test.go b/tests/keys_test.go index 33ed1ea6..05bee5e8 100644 --- a/tests/keys_test.go +++ b/tests/keys_test.go @@ -180,7 +180,15 @@ func keys_FSET_test(mc *mockServer) error { Do("GET", "mykey", "myid2").Str(""), Do("DEL", "mykey", "myid").Str("1"), Do("GET", "mykey", "myid").Str(""), + Do("SET", "mykey", "myid", "POINT", 1, 2).OK(), + Do("GET", "mykey", "myid", "WITHFIELDS").JSON().Str(`{"ok":true,"object":{"type":"Point","coordinates":[2,1]}}`), + Do("FSET", "mykey", "myid", "f2", 1).JSON().OK(), + Do("GET", "mykey", "myid", "WITHFIELDS").JSON().Str(`{"ok":true,"object":{"type":"Point","coordinates":[2,1]},"fields":{"f2":1}}`), + Do("SET", "mykey", "myid", "POINT", 3, 4).OK(), + Do("GET", "mykey", "myid", "WITHFIELDS").JSON().Str(`{"ok":true,"object":{"type":"Point","coordinates":[4,3]},"fields":{"f2":1}}`), Do("SET", "mykey", "myid", "HASH", "9my5xp7").OK(), + Do("DEL", "mykey", "myid").Str("1"), + Do("GET", "mykey", "myid").Str(""), Do("CONFIG", "SET", "maxmemory", "1").OK(), Do("FSET", "mykey", "myid", "xx", "f1", 1.1, "f2", 2.2).Err(`OOM command not allowed when used memory > 'maxmemory'`), Do("CONFIG", "SET", "maxmemory", "0").OK(),