thi-ng/trio

optional queries should be skipped if prev result empty (seq), but not `::empty`

postspectacular opened this issue · 0 comments

(q/query
  {:select :*
   :from '[[a knows b] [b name bar]]
   :query [{:where '[[a ?p ?o]]
            :filter {'?p #(not= % 'knows)}}
           {:optional '[[?p name ?n]]}]})

This example should fail since the first sub-query fails, but instead the optional query is still run and produces a misleading result:

#{{?n bar, ?p b}}

TODO: add check in query-step if prev result ((qfn a)) is empty seq and if so do not proceed...