empty results when key not found, #207

This commit is contained in:
Josh Baker 2017-08-03 04:01:07 -07:00
parent aafae38412
commit e2357eac3e
1 changed files with 29 additions and 30 deletions

View File

@ -400,13 +400,11 @@ func (c *Controller) cmdWithinOrIntersects(cmd string, msg *server.Message) (res
if err != nil { if err != nil {
return "", err return "", err
} }
if sw.col == nil {
return "", errKeyNotFound
}
if msg.OutputType == server.JSON { if msg.OutputType == server.JSON {
wr.WriteString(`{"ok":true`) wr.WriteString(`{"ok":true`)
} }
sw.writeHead() sw.writeHead()
if sw.col != nil {
minZ, maxZ := zMinMaxFromWheres(s.wheres) minZ, maxZ := zMinMaxFromWheres(s.wheres)
if cmd == "within" { if cmd == "within" {
sw.col.Within(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ, sw.col.Within(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ,
@ -435,6 +433,7 @@ func (c *Controller) cmdWithinOrIntersects(cmd string, msg *server.Message) (res
}, },
) )
} }
}
sw.writeFoot() sw.writeFoot()
if msg.OutputType == server.JSON { if msg.OutputType == server.JSON {
wr.WriteString(`,"elapsed":"` + time.Now().Sub(start).String() + "\"}") wr.WriteString(`,"elapsed":"` + time.Now().Sub(start).String() + "\"}")