From 757177d340e1748a6ac043376598e8e419e90acb Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Fri, 2 Jun 2023 15:06:16 +0200 Subject: [PATCH] fix(cognitarium): return empty iter on not found triple iter load --- contracts/okp4-cognitarium/src/querier/engine.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contracts/okp4-cognitarium/src/querier/engine.rs b/contracts/okp4-cognitarium/src/querier/engine.rs index 991f6074..fdb32cbe 100644 --- a/contracts/okp4-cognitarium/src/querier/engine.rs +++ b/contracts/okp4-cognitarium/src/querier/engine.rs @@ -244,9 +244,13 @@ impl<'a> TriplePatternIterator<'a> { filters: TriplePatternFilters, ) -> Box> + 'a> { match filters { - (Some(s), Some(p), Some(o)) => Box::new(iter::once( - triples().load(storage, (o.as_hash().as_bytes(), p.key(), s.key())), - )), + (Some(s), Some(p), Some(o)) => { + let res = triples().load(storage, (o.as_hash().as_bytes(), p.key(), s.key())); + match res { + Err(StdError::NotFound { .. }) => Box::new(iter::empty()), + _ => Box::new(iter::once(res)), + } + } (Some(s), Some(p), None) => Box::new( triples() .idx