diff --git a/internal/field/field.go b/internal/field/field.go index 899c447b..a14d9d89 100644 --- a/internal/field/field.go +++ b/internal/field/field.go @@ -226,7 +226,7 @@ func ValueOf(data string) Value { func Make(name, data string) Field { return Field{ - strings.ToLower(strings.TrimSpace(name)), + strings.TrimSpace(name), ValueOf(data), } } diff --git a/internal/field/field_test.go b/internal/field/field_test.go index 84b25ef1..26830a03 100644 --- a/internal/field/field_test.go +++ b/internal/field/field_test.go @@ -119,7 +119,7 @@ func TestJSON(t *testing.T) { func TestField(t *testing.T) { assert.Assert(Make("hello", "123").Name() == "hello") - assert.Assert(Make("HELLO", "123").Name() == "hello") + assert.Assert(Make("HELLO", "123").Name() == "HELLO") assert.Assert(Make("HELLO", "123").Value().Num() == 123) assert.Assert(Make("HELLO", "123").Value().JSON() == "123") assert.Assert(Make("HELLO", "123").Value().Num() == 123) diff --git a/internal/server/crud.go b/internal/server/crud.go index a0fc727d..b43c7d51 100644 --- a/internal/server/crud.go +++ b/internal/server/crud.go @@ -600,7 +600,7 @@ func (s *Server) cmdSET(msg *Message) (resp.Value, commandDetails, error) { if i+2 >= len(args) { return retwerr(errInvalidNumberOfArguments) } - fkey := strings.ToLower(args[i+1]) + fkey := args[i+1] fval := args[i+2] i += 2 if isReservedFieldName(fkey) { diff --git a/internal/server/token.go b/internal/server/token.go index 3ccf5f68..24b35a12 100644 --- a/internal/server/token.go +++ b/internal/server/token.go @@ -321,7 +321,7 @@ func (s *Server) parseSearchScanBaseTokens( } } t.wheres = append(t.wheres, whereT{ - name: strings.ToLower(name), + name: name, minx: minx, min: field.ValueOf(smin), maxx: maxx, diff --git a/tests/keys_test.go b/tests/keys_test.go index 945487d2..33ed1ea6 100644 --- a/tests/keys_test.go +++ b/tests/keys_test.go @@ -480,6 +480,41 @@ func keys_FIELDS_test(mc *mockServer) error { Do("SCAN", "fleet", "WHERE", "properties.speed", ">", 49, "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), Do("SCAN", "fleet", "WHERE", "properties.speed", ">", 50, "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), Do("SCAN", "fleet", "WHERE", "properties.speed", "<", 51, "IDS").JSON().Str(`{"ok":true,"ids":["truck1","truck2"],"count":2,"cursor":0}`), + + Do("DROP", "fleet").JSON().OK(), + Do("SET", "fleet", "truck1", "FIELD", "speed", "50", "POINT", "-112", "33").JSON().OK(), + Do("SET", "fleet", "truck1", "FIELD", "Speed", "51", "POINT", "-112", "33").JSON().OK(), + Do("SET", "fleet", "truck1", "FIELD", "speeD", "52", "POINT", "-112", "33").JSON().OK(), + Do("SET", "fleet", "truck1", "FIELD", "SpeeD", "53", "POINT", "-112", "33").JSON().OK(), + Do("GET", "fleet", "truck1", "WITHFIELDS").JSON().Str(`{"ok":true,"object":{"type":"Point","coordinates":[33,-112]},"fields":{"SpeeD":53,"Speed":51,"speeD":52,"speed":50}}`), + Do("SCAN", "fleet", "WHERE", "speed == 50", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Speed == 50", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Speed == 51", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "speed", 50, 50, "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Speed", 51, 51, "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Speed", 50, 50, "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "speed", 51, 51, "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + + Do("DROP", "fleet").JSON().OK(), + Do("SET", "fleet", "truck1", "field", "props", `{"speed":50,"Speed":51}`, "point", "33", "-112").JSON().OK(), + Do("SET", "fleet", "truck1", "field", "Props", `{"speed":52,"Speed":53}`, "point", "33", "-112").JSON().OK(), + Do("GET", "fleet", "truck1", "WITHFIELDS").JSON().Str(`{"ok":true,"object":{"type":"Point","coordinates":[-112,33]},"fields":{"Props":{"speed":52,"Speed":53},"props":{"speed":50,"Speed":51}}}`), + Do("SCAN", "fleet", "WHERE", "props.speed == 50", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "props.Speed == 51", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.speed == 52", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.Speed == 53", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "props.Speed == 52", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "props.speed == 51", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.speed == 53", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.Speed == 50", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "props.speed > 49", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "props.Speed > 49", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.speed > 49", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.Speed > 49", "IDS").JSON().Str(`{"ok":true,"ids":["truck1"],"count":1,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "props.Speed > 53", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "props.speed > 53", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.speed > 53", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), + Do("SCAN", "fleet", "WHERE", "Props.Speed > 53", "IDS").JSON().Str(`{"ok":true,"ids":[],"count":0,"cursor":0}`), ) }