Skip to content

Commit 66a40ae

Browse files
noxpardalisbilelmoussaoui
authored andcommitted
server: match items if search attributes are a subset
Change attribute comparison to match on lookups where the search attributes form a subset of the item's attributes. Fixes #233
1 parent e00ed43 commit 66a40ae

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

server/src/collection.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,16 @@ impl Collection {
229229
let mut items = Vec::new();
230230

231231
for item in self.items.lock().await.iter() {
232-
if item.attributes().await == *attributes {
232+
let item_attributes = item.attributes().await;
233+
234+
// Check if the (key, value) pairs in the requested attributes are
235+
// a subset of the attributes in the item being checked for in the
236+
// collection.
237+
let attributes_are_subset = attributes
238+
.iter()
239+
.all(|(key, value)| item_attributes.get(key) == Some(value));
240+
241+
if attributes_are_subset {
233242
items.push(item.clone());
234243
}
235244
}

0 commit comments

Comments
 (0)