Skip to content

Commit

Permalink
Merge pull request #1357 from anyproto/go-2973-fix-filter-in
Browse files Browse the repository at this point in the history
GO-2973 Add FilterIn
  • Loading branch information
requilence committed Jul 2, 2024
2 parents 28abe30 + fc044f5 commit e45ace9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/lib/localstore/objectstore/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,13 @@ func getSpaceIDFromFilter(fltr database.Filter) (spaceID string) {
if f.Key == bundle.RelationKeySpaceId.String() {
return f.Value.GetStringValue()
}
case database.FilterIn:
if f.Key == bundle.RelationKeySpaceId.String() {
values := f.Value.GetValues()
if len(values) > 0 {
return values[0].GetStringValue()
}
}
case database.FiltersAnd:
spaceID = iterateOverAndFilters(f)
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/lib/localstore/objectstore/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,17 @@ func TestGetSpaceIDFromFilters(t *testing.T) {
assert.Equal(t, "", getSpaceIDFromFilter(f))
})

t.Run("filters is filter.FilterIn with spaceId", func(t *testing.T) {
list, err := pbtypes.ValueListWrapper(pbtypes.StringList([]string{"space1", "space2"}))
assert.NoError(t, err)

f := database.FilterIn{
Key: bundle.RelationKeySpaceId.String(),
Value: list,
}
assert.Equal(t, "space1", getSpaceIDFromFilter(f))
})

t.Run("spaceID is nested in and filters", func(t *testing.T) {
spaceID := "secret_space"
f := database.FiltersAnd{
Expand Down

0 comments on commit e45ace9

Please sign in to comment.