I opened a Github issue for this: advanced query with “get-else” yields error · Issue #6184 · logseq/logseq · GitHub
expand the origianl forum post
my example is based on this message: Advanced Query for NOW or due today/overdue - #12 by quor
i’m trying to modify the query and make it also emit blocks that don’t have a marker. in my mind that only needs changing one line:
#+BEGIN_QUERY
{ :query [:find (pull ?b [*])
:in $ ?today ?tomorrow
:where
- [?b :block/marker ?m]
+ [(get-else $ ?b :block/marker "NA") ?m]
(not [(contains? #{"DONE", "CANCELED"} ?m)])
[(get-else $ ?b :block/scheduled ?tomorrow) ?scheduled]
[(get-else $ ?b :block/deadline ?tomorrow) ?deadline]
(or
[(contains? #{"NOW", "DOING"} ?m)]
[(<= ?scheduled ?today)]
[(<= ?deadline ?today)])]
:inputs [:today 99990101]
:result-transform (fn [result]
(sort-by (fn [h]
(get-in h [:block/scheduled])) result))
:breadcrumb-show? false}
#+END_QUERY
however, this change leads to a query error that i found via the developer tools:
#error {:message “Insufficient bindings: #{?b} not bound in [(get-else $ ?b :block/marker “NA”) ?m]”, :data {:error :query/where, :form [(get-else $ ?b :block/marker “NA”) ?m], :vars #{?b}}}
Error: Insufficient bindings: #{?b} not bound in [(get-else $ ?b :block/marker “NA”) ?m]
i have looked at numerous examples on how get-else
can be used and cannot figure out what i’m doing wrong.
logseq: 0.7.8
platform: linux