Skip to content

Commit

Permalink
fix: FSET lowercasing upper case fields
Browse files Browse the repository at this point in the history
fixes #741
  • Loading branch information
iwpnd committed May 25, 2024
1 parent 51e6862 commit 718bff5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/server/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,8 @@ func (s *Server) cmdFSET(msg *Message) (resp.Value, commandDetails, error) {
}
key, id = args[1], args[2]
for i := 3; i < len(args); i++ {
arg := strings.ToLower(args[i])
switch arg {
arg := args[i]
switch strings.ToLower(arg) {
case "xx":
xx = true
default:
Expand Down
22 changes: 22 additions & 0 deletions tests/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@ func keys_FSET_test(mc *mockServer) error {
Do("FSET", "mykey2", "myid", "a", "b").Err("key not found"),
Do("FSET", "mykey", "myid2", "a", "b").Err("id not found"),
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 {
Expand Down

0 comments on commit 718bff5

Please sign in to comment.