[#142] metabase: Fix false-positive select in absence of filtered header

Fix a bug in the selection when the object without some filtered header
added to the final result.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-03 17:24:23 +03:00 committed by Alex Vanin
parent 3c39c5a90c
commit 62bd22a379
2 changed files with 50 additions and 16 deletions

View file

@ -152,3 +152,35 @@ func TestSelectRemoved(t *testing.T) {
testSelect(t, db, fs, obj2.Address())
}
func TestMissingObjectAttribute(t *testing.T) {
db := newDB(t)
defer releaseDB(db)
// add object w/o attribute
obj1 := generateObject(t, testPrm{
attrNum: 1,
})
// add object w/o attribute
obj2 := generateObject(t, testPrm{})
a1 := obj1.GetAttributes()[0]
// add common attribute
aCommon := addCommonAttribute(obj1, obj2)
// write to DB
require.NoError(t, db.Put(obj1))
require.NoError(t, db.Put(obj2))
fs := objectSDK.SearchFilters{}
// 1st filter by common attribute
fs.AddFilter(aCommon.GetKey(), aCommon.GetValue(), objectSDK.MatchStringEqual)
// next filter by attribute from 1st object only
fs.AddFilter(a1.GetKey(), a1.GetValue(), objectSDK.MatchStringEqual)
testSelect(t, db, fs, obj1.Address())
}