This commit is contained in:
Alex Roitman 2020-04-09 09:59:24 -07:00
parent fe0216c42c
commit 914f51de11

View File

@ -119,18 +119,18 @@ func (s *Server) newScanWriter(
// so we don't have to map string field names for each tested object // so we don't have to map string field names for each tested object
var ok bool var ok bool
if len(wheres) > 0 { if len(wheres) > 0 {
sw.wheres = make([]whereT, 0, len(wheres)) sw.wheres = make([]whereT, len(wheres))
for i, where := range wheres { for i, where := range wheres {
if where.index, ok = sw.fmap[where.field]; ok { if where.index, ok = sw.fmap[where.field]; !ok {
where.index = math.MaxInt32 where.index = math.MaxInt32
} }
sw.wheres[i] = where sw.wheres[i] = where
} }
} }
if len(whereins) > 0 { if len(whereins) > 0 {
sw.whereins = make([]whereinT, 0, len(whereins)) sw.whereins = make([]whereinT, len(whereins))
for i, wherein := range whereins { for i, wherein := range whereins {
if wherein.index, ok = sw.fmap[wherein.field]; ok { if wherein.index, ok = sw.fmap[wherein.field]; !ok {
wherein.index = math.MaxInt32 wherein.index = math.MaxInt32
} }
sw.whereins[i] = wherein sw.whereins[i] = wherein
@ -231,7 +231,7 @@ func (sw *scanWriter) fieldMatch(fields []float64, o geojson.Object) (fvals []fl
continue continue
} }
var value float64 var value float64
if len(fields) > where.index { if where.index < len(fields) {
value = fields[where.index] value = fields[where.index]
} }
if !where.match(value) { if !where.match(value) {
@ -240,7 +240,7 @@ func (sw *scanWriter) fieldMatch(fields []float64, o geojson.Object) (fvals []fl
} }
for _, wherein := range sw.whereins { for _, wherein := range sw.whereins {
var value float64 var value float64
if len(fields) > wherein.index { if wherein.index < len(fields) {
value = fields[wherein.index] value = fields[wherein.index]
} }
if !wherein.match(value) { if !wherein.match(value) {