1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 02:13:41 +09:00

GO-2973 Add FilterIn

This commit is contained in:
Mikhail Iudin 2024-07-01 13:53:20 +02:00
parent 60a1e0fd90
commit fc044f5aa4
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
2 changed files with 18 additions and 0 deletions

View file

@ -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)
}

View file

@ -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{