[#142] metabase: Fix false-positive select

Fix a bug in the selection when an object could be added to the result after
a mismatch in the previous filter.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-03 16:12:34 +03:00 committed by Alex Vanin
parent 77e80f517f
commit 7a8f322d59
2 changed files with 34 additions and 5 deletions

View file

@ -88,3 +88,26 @@ func BenchmarkDB_Select(b *testing.B) {
})
}
}
func TestMismatchAfterMatch(t *testing.T) {
db := newDB(t)
defer releaseDB(db)
obj := generateObject(t, testPrm{
attrNum: 1,
})
require.NoError(t, db.Put(obj))
a := obj.GetAttributes()[0]
fs := objectSDK.SearchFilters{}
// 1st - mismatching filter
fs.AddFilter(a.GetKey(), a.GetValue()+"1", objectSDK.MatchStringEqual)
// 2nd - matching filter
fs.AddFilter(a.GetKey(), a.GetValue(), objectSDK.MatchStringEqual)
testSelect(t, db, fs)
}