fix: Insufficient bindings error after datascript upgrade

After upgrading our forked datascript from 1.5.3 to 1.7.1,
bindings in two of our rules behaved differently. The workaround
of adding an `and` where none was required before is sufficient.
Fixes LOG-3177
feat/tables
Gabriel Horner 2024-06-27 16:11:29 -04:00 committed by Tienson Qin
parent 99769dbcbf
commit d7adee57e8
4 changed files with 20 additions and 9 deletions

3
deps/db/bb.edn vendored
View File

@ -31,7 +31,8 @@
(concat (mapcat val rules/rules)
;; TODO: Update linter to handle false positive on ?str-val for :property
(rules/extract-rules (dissoc rules/query-dsl-rules :property))
(rules/extract-rules rules/db-query-dsl-rules))))}}
;; TODO: Update linter to handle false positive on :task and :priority
(rules/extract-rules (dissoc rules/db-query-dsl-rules :task :priority)))))}}
:tasks/config
{:large-vars

View File

@ -196,13 +196,15 @@
:task
'[(task ?b ?statuses)
(property ?b :logseq.task/status ?status)
[(contains? ?statuses ?status)]]
;; and needed to avoid binding error
(and (property ?b :logseq.task/status ?val)
[(contains? ?statuses ?val)])]
:priority
'[(priority ?b ?priorities)
(property ?b :logseq.task/priority ?priority)
[(contains? ?priorities ?priority)]]}))
;; and needed to avoid binding error
(and (property ?b :logseq.task/priority ?priority)
[(contains? ?priorities ?priority)])]}))
(def rules-dependencies
"For db graphs, a map of rule names and the rules they depend on. If this map

View File

@ -7,9 +7,9 @@
logseq/db {:local/root "../db"}
logseq/common {:local/root "../common"}
;; stubbed in nbb
funcool/promesa {:mvn/version "4.0.2"}
com.lambdaisland/glogi {:mvn/version "1.1.144"}
;; built in to nbb
funcool/promesa {:mvn/version "4.0.2"}
cljs-bean/cljs-bean {:mvn/version "1.5.0"}}
:aliases

View File

@ -289,6 +289,14 @@ prop-d:: [[nada]]"}])
(map testable-content
(dsl-query "(and (task doing) (or [[A]] [[B]]))")))))
(when js/process.env.DB_GRAPH
;; Ensure some filters work when no data with relevant properties exist
(deftest queries-with-no-data
(load-test-files [])
(is (= [] (dsl-query "(task todo)")))
(is (= [] (dsl-query "(priority high)")))))
(deftest sample-queries
(load-test-files [{:file/path "pages/page1.md"
:file/content "foo:: bar