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:
parent
60a1e0fd90
commit
fc044f5aa4
2 changed files with 18 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue