Skip to content

Commit

Permalink
in/not-in works on gcpfirestore
Browse files Browse the repository at this point in the history
  • Loading branch information
coryschwartz authored and vangent committed Dec 22, 2023
1 parent 4fe95ee commit 7d2924e
Show file tree
Hide file tree
Showing 11 changed files with 451 additions and 584 deletions.
16 changes: 16 additions & 0 deletions docstore/awsdynamodb/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"io"
"reflect"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -436,11 +437,26 @@ func toFilter(f driver.Filter) expression.ConditionBuilder {
return expression.GreaterThanEqual(name, val)
case ">":
return expression.GreaterThan(name, val)
case "in":
return toInCondition(f)
case "not-in":
return expression.Not(toInCondition(f))
default:
panic(fmt.Sprint("invalid filter operation:", f.Op))
}
}

func toInCondition(f driver.Filter) expression.ConditionBuilder {
name := expression.Name(strings.Join(f.FieldPath, "."))
vslice := reflect.ValueOf(f.Value)
right := expression.Value(vslice.Index(0).Interface())
other := make([]expression.OperandBuilder, vslice.Len()-1)
for i := 1; i < vslice.Len(); i++ {
other[i-1] = expression.Value(vslice.Index(i).Interface())
}
return expression.In(name, right, other...)
}

type documentIterator struct {
qr *queryRunner
items []map[string]*dyn.AttributeValue
Expand Down
442 changes: 276 additions & 166 deletions docstore/awsdynamodb/testdata/TestConformance/GetQuery.replay

Large diffs are not rendered by default.

Loading

0 comments on commit 7d2924e

Please sign in to comment.