mirror of https://github.com/tidwall/tile38.git
Fixed fields not persisting
This commit fixes a regression in 1.30.0, where an existing object which has fields will lose those fields when the object geometry is overwritten using a SET or JSET and no new fields are provided. fixes #668
This commit is contained in:
parent
44396072a5
commit
4e67d1497c
|
@ -746,16 +746,11 @@ func (s *Server) cmdSET(msg *Message) (resp.Value, commandDetails, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var flist field.List
|
var flist field.List
|
||||||
if len(fields) > 0 {
|
if old := col.Get(id); old != nil {
|
||||||
old := col.Get(id)
|
flist = old.Fields()
|
||||||
if old != nil {
|
}
|
||||||
flist = old.Fields()
|
for _, f := range fields {
|
||||||
}
|
flist = flist.Set(f)
|
||||||
for _, f := range fields {
|
|
||||||
flist = flist.Set(f)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
flist = field.MakeList(fields)
|
|
||||||
}
|
}
|
||||||
obj := object.New(id, oobj, ex, flist)
|
obj := object.New(id, oobj, ex, flist)
|
||||||
old := col.Set(obj)
|
old := col.Set(obj)
|
||||||
|
|
|
@ -180,7 +180,15 @@ func keys_FSET_test(mc *mockServer) error {
|
||||||
Do("GET", "mykey", "myid2").Str("<nil>"),
|
Do("GET", "mykey", "myid2").Str("<nil>"),
|
||||||
Do("DEL", "mykey", "myid").Str("1"),
|
Do("DEL", "mykey", "myid").Str("1"),
|
||||||
Do("GET", "mykey", "myid").Str("<nil>"),
|
Do("GET", "mykey", "myid").Str("<nil>"),
|
||||||
|
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("SET", "mykey", "myid", "HASH", "9my5xp7").OK(),
|
||||||
|
Do("DEL", "mykey", "myid").Str("1"),
|
||||||
|
Do("GET", "mykey", "myid").Str("<nil>"),
|
||||||
Do("CONFIG", "SET", "maxmemory", "1").OK(),
|
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("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(),
|
Do("CONFIG", "SET", "maxmemory", "0").OK(),
|
||||||
|
|
Loading…
Reference in New Issue