fix: FSET lowercasing upper case fields

fixes #741
This commit is contained in:
Benjamin Ramser 2024-05-25 12:16:58 +02:00
parent 51e6862797
commit 718bff54c1
2 changed files with 24 additions and 2 deletions

View File

@ -841,8 +841,8 @@ func (s *Server) cmdFSET(msg *Message) (resp.Value, commandDetails, error) {
} }
key, id = args[1], args[2] key, id = args[1], args[2]
for i := 3; i < len(args); i++ { for i := 3; i < len(args); i++ {
arg := strings.ToLower(args[i]) arg := args[i]
switch arg { switch strings.ToLower(arg) {
case "xx": case "xx":
xx = true xx = true
default: default:

View File

@ -202,6 +202,28 @@ func keys_FSET_test(mc *mockServer) error {
Do("FSET", "mykey2", "myid", "a", "b").Err("key not found"), Do("FSET", "mykey2", "myid", "a", "b").Err("key not found"),
Do("FSET", "mykey", "myid2", "a", "b").Err("id not found"), Do("FSET", "mykey", "myid2", "a", "b").Err("id not found"),
Do("FSET", "mykey", "myid", "f2", 0).JSON().OK(), Do("FSET", "mykey", "myid", "f2", 0).JSON().OK(),
Do("SET", "cases", "lower", "POINT", 1, 2).OK(),
Do("FSET", "cases", "lower", "lowercase", 1).JSON().OK(),
Do("GET", "cases", "lower", "WITHFIELDS").JSON().Str(
`{"ok":true,"object":{"type":"Point","coordinates":[2,1]},"fields":{"lowercase":1}}`,
),
Do("SET", "cases", "upper", "POINT", 1, 2).OK(),
Do("FSET", "cases", "upper", "UPPERCASE", 1).JSON().OK(),
Do("GET", "cases", "upper", "WITHFIELDS").JSON().Str(
`{"ok":true,"object":{"type":"Point","coordinates":[2,1]},"fields":{"UPPERCASE":1}}`,
),
Do("SET", "cases", "camel", "POINT", 1, 2).OK(),
Do("FSET", "cases", "camel", "camelCase", 1).JSON().OK(),
Do("GET", "cases", "camel", "WITHFIELDS").JSON().Str(
`{"ok":true,"object":{"type":"Point","coordinates":[2,1]},"fields":{"camelCase":1}}`,
),
Do("SET", "cases", "allcases", "POINT", 1, 2).OK(),
Do("FSET", "cases", "allcases", "UPPERCASE", 1).JSON().OK(),
Do("FSET", "cases", "allcases", "lowercase", 1).JSON().OK(),
Do("FSET", "cases", "allcases", "camelCase", 1).JSON().OK(),
Do("GET", "cases", "allcases", "WITHFIELDS").JSON().Str(
`{"ok":true,"object":{"type":"Point","coordinates":[2,1]},"fields":{"UPPERCASE":1,"camelCase":1,"lowercase":1}}`,
),
) )
} }
func keys_FGET_test(mc *mockServer) error { func keys_FGET_test(mc *mockServer) error {