[#223] object: Introduce ec_parent search filter

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-05-14 13:06:30 +03:00
parent d4e6f4e125
commit 09b79d13f3
2 changed files with 24 additions and 0 deletions

View file

@ -120,6 +120,7 @@ const (
fKeySplitID fKeySplitID
fKeyPropRoot fKeyPropRoot
fKeyPropPhy fKeyPropPhy
fKeyECParent
) )
func (k filterKey) String() string { func (k filterKey) String() string {
@ -152,6 +153,8 @@ func (k filterKey) String() string {
return v2object.FilterPropertyRoot return v2object.FilterPropertyRoot
case fKeyPropPhy: case fKeyPropPhy:
return v2object.FilterPropertyPhy return v2object.FilterPropertyPhy
case fKeyECParent:
return v2object.FilterHeaderECParent
} }
} }
@ -277,6 +280,10 @@ func (f *SearchFilters) AddSplitIDFilter(m SearchMatchType, id *SplitID) {
f.addReservedFilter(m, fKeySplitID, staticStringer(id.String())) f.addReservedFilter(m, fKeySplitID, staticStringer(id.String()))
} }
func (f *SearchFilters) AddECParentFilter(m SearchMatchType, parentID oid.ID) {
f.addReservedFilter(m, fKeyECParent, staticStringer(parentID.String()))
}
// AddTypeFilter adds filter by object type. // AddTypeFilter adds filter by object type.
func (f *SearchFilters) AddTypeFilter(m SearchMatchType, typ Type) { func (f *SearchFilters) AddTypeFilter(m SearchMatchType, typ Type) {
f.addReservedFilter(m, fKeyType, staticStringer(typ.String())) f.addReservedFilter(m, fKeyType, staticStringer(typ.String()))

View file

@ -160,6 +160,23 @@ func TestSearchFilters_AddSplitIDFilter(t *testing.T) {
}) })
} }
func TestSearchFilters_AddECParentFilter(t *testing.T) {
id := testOID()
fs := new(object.SearchFilters)
fs.AddECParentFilter(object.MatchStringEqual, id)
t.Run("v2", func(t *testing.T) {
fsV2 := fs.ToV2()
require.Len(t, fsV2, 1)
require.Equal(t, v2object.FilterHeaderECParent, fsV2[0].GetKey())
require.Equal(t, id.String(), fsV2[0].GetValue())
require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType())
})
}
func TestSearchFilters_AddTypeFilter(t *testing.T) { func TestSearchFilters_AddTypeFilter(t *testing.T) {
typ := object.TypeTombstone typ := object.TypeTombstone