[#254] object: Support new values of search match type

Support STRING_NOT_EQUAL and NOT_PRESENT match types
of object search filters.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-01 20:57:18 +03:00 committed by Alex Vanin
parent e9ae408c3a
commit ebff07aaf2
5 changed files with 16 additions and 2 deletions

View file

@ -15,12 +15,18 @@ type SearchMatchType uint32
const ( const (
MatchUnknown SearchMatchType = iota MatchUnknown SearchMatchType = iota
MatchStringEqual MatchStringEqual
MatchStringNotEqual
MatchNotPresent
) )
func (m SearchMatchType) ToV2() v2object.MatchType { func (m SearchMatchType) ToV2() v2object.MatchType {
switch m { switch m {
case MatchStringEqual: case MatchStringEqual:
return v2object.MatchStringEqual return v2object.MatchStringEqual
case MatchStringNotEqual:
return v2object.MatchStringNotEqual
case MatchNotPresent:
return v2object.MatchNotPresent
default: default:
return v2object.MatchUnknown return v2object.MatchUnknown
} }
@ -30,6 +36,10 @@ func SearchMatchFromV2(t v2object.MatchType) (m SearchMatchType) {
switch t { switch t {
case v2object.MatchStringEqual: case v2object.MatchStringEqual:
m = MatchStringEqual m = MatchStringEqual
case v2object.MatchStringNotEqual:
m = MatchStringNotEqual
case v2object.MatchNotPresent:
m = MatchNotPresent
default: default:
m = MatchUnknown m = MatchUnknown
} }

View file

@ -12,8 +12,10 @@ import (
var ( var (
eqV2Matches = map[object.SearchMatchType]v2object.MatchType{ eqV2Matches = map[object.SearchMatchType]v2object.MatchType{
object.MatchUnknown: v2object.MatchUnknown, object.MatchUnknown: v2object.MatchUnknown,
object.MatchStringEqual: v2object.MatchStringEqual, object.MatchStringEqual: v2object.MatchStringEqual,
object.MatchStringNotEqual: v2object.MatchStringNotEqual,
object.MatchNotPresent: v2object.MatchNotPresent,
} }
) )

Binary file not shown.

Binary file not shown.

View file

@ -226,6 +226,8 @@ const (
const ( const (
MatchUnknown MatchType = iota MatchUnknown MatchType = iota
MatchStringEqual MatchStringEqual
MatchStringNotEqual
MatchNotPresent
) )
func (h *ShortHeader) GetVersion() *refs.Version { func (h *ShortHeader) GetVersion() *refs.Version {