mirror of https://github.com/tidwall/tile38.git
Fix field names converting to lowercase
This commit is contained in:
parent
e267ddf58c
commit
e60ea706aa
|
@ -226,7 +226,7 @@ func ValueOf(data string) Value {
|
||||||
|
|
||||||
func Make(name, data string) Field {
|
func Make(name, data string) Field {
|
||||||
return Field{
|
return Field{
|
||||||
strings.ToLower(strings.TrimSpace(name)),
|
strings.TrimSpace(name),
|
||||||
ValueOf(data),
|
ValueOf(data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ func TestJSON(t *testing.T) {
|
||||||
|
|
||||||
func TestField(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").Name() == "HELLO")
|
||||||
assert.Assert(Make("HELLO", "123").Value().Num() == 123)
|
assert.Assert(Make("HELLO", "123").Value().Num() == 123)
|
||||||
assert.Assert(Make("HELLO", "123").Value().JSON() == "123")
|
assert.Assert(Make("HELLO", "123").Value().JSON() == "123")
|
||||||
assert.Assert(Make("HELLO", "123").Value().Num() == 123)
|
assert.Assert(Make("HELLO", "123").Value().Num() == 123)
|
||||||
|
|
|
@ -600,7 +600,7 @@ func (s *Server) cmdSET(msg *Message) (resp.Value, commandDetails, error) {
|
||||||
if i+2 >= len(args) {
|
if i+2 >= len(args) {
|
||||||
return retwerr(errInvalidNumberOfArguments)
|
return retwerr(errInvalidNumberOfArguments)
|
||||||
}
|
}
|
||||||
fkey := strings.ToLower(args[i+1])
|
fkey := args[i+1]
|
||||||
fval := args[i+2]
|
fval := args[i+2]
|
||||||
i += 2
|
i += 2
|
||||||
if isReservedFieldName(fkey) {
|
if isReservedFieldName(fkey) {
|
||||||
|
|
|
@ -321,7 +321,7 @@ func (s *Server) parseSearchScanBaseTokens(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.wheres = append(t.wheres, whereT{
|
t.wheres = append(t.wheres, whereT{
|
||||||
name: strings.ToLower(name),
|
name: name,
|
||||||
minx: minx,
|
minx: minx,
|
||||||
min: field.ValueOf(smin),
|
min: field.ValueOf(smin),
|
||||||
maxx: maxx,
|
maxx: maxx,
|
||||||
|
|
|
@ -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", ">", 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", ">", 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("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}`),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue