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,40 +400,39 @@ 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()
minZ, maxZ := zMinMaxFromWheres(s.wheres) if sw.col != nil {
if cmd == "within" { minZ, maxZ := zMinMaxFromWheres(s.wheres)
sw.col.Within(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ, if cmd == "within" {
func(id string, o geojson.Object, fields []float64) bool { sw.col.Within(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ,
if c.hasExpired(s.key, id) { func(id string, o geojson.Object, fields []float64) bool {
return true if c.hasExpired(s.key, id) {
} return true
return sw.writeObject(ScanWriterParams{ }
id: id, return sw.writeObject(ScanWriterParams{
o: o, id: id,
fields: fields, o: o,
}) fields: fields,
}, })
) },
} else if cmd == "intersects" { )
sw.col.Intersects(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ, } else if cmd == "intersects" {
func(id string, o geojson.Object, fields []float64) bool { sw.col.Intersects(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ,
if c.hasExpired(s.key, id) { func(id string, o geojson.Object, fields []float64) bool {
return true if c.hasExpired(s.key, id) {
} return true
return sw.writeObject(ScanWriterParams{ }
id: id, return sw.writeObject(ScanWriterParams{
o: o, id: id,
fields: fields, o: o,
}) fields: fields,
}, })
) },
)
}
} }
sw.writeFoot() sw.writeFoot()
if msg.OutputType == server.JSON { if msg.OutputType == server.JSON {