mirror of
https://github.com/logseq/logseq.git
synced 2026-05-04 19:06:21 +00:00
Fix page-ref rule which was not bindable and failed fast
- page-ref had a :block/name embedded lookup ref which failed fast. datomic advises against this - https://docs.datomic.com/on-prem/schema/identity.html#:~:text=You%20cannot%20use%20them%20in%20the%20body%20of%20a%20query%2C%20use%20datalog%20clauses%20instead - page-ref can handle binding args like last commit for page - page-ref not failing fast on non-existing pages means that user can get meaningful results in more complex queries as seen in test - Also remove try/catch as there should be no more queries that unintentionally cause the 'Nothing found for entity' error - Also fixed lookup ref in srs cards which can be seen in stacktrace of #4576
This commit is contained in:
committed by
Tienson Qin
parent
3282d1c766
commit
6b935a8d58
@@ -355,12 +355,7 @@ tags: other
|
||||
nil
|
||||
""
|
||||
" "
|
||||
"\"\""))
|
||||
|
||||
(testing "Non exists page should be ignored"
|
||||
(are [x] (nil? (dsl-query x))
|
||||
"[[page-not-exist]]"
|
||||
"[[another-page-not-exist]]")))
|
||||
"\"\"")))
|
||||
|
||||
(deftest page-ref-and-boolean-queries
|
||||
(load-test-files [{:file/path "pages/page1.md"
|
||||
@@ -380,8 +375,8 @@ tags: other
|
||||
"Tag arg")
|
||||
|
||||
(is (= []
|
||||
(map :block/content (dsl-query "[[blarg]]")))
|
||||
"Correctly returns no results"))
|
||||
(dsl-query "[[blarg]]"))
|
||||
"Nonexistent page returns no results"))
|
||||
|
||||
(testing "basic boolean queries"
|
||||
(is (= ["b2 [[page 2]] #tag1"]
|
||||
@@ -394,6 +389,11 @@ tags: other
|
||||
(dsl-query "(or [[tag2]] [[page 2]])")))
|
||||
"OR query")
|
||||
|
||||
(is (= ["b1 [[page 1]] #tag2"]
|
||||
(map :block/content
|
||||
(dsl-query "(or [[tag2]] [[page 3]])")))
|
||||
"OR query with nonexistent page should return meaningful results")
|
||||
|
||||
(is (= ["foo:: bar\n" "b1 [[page 1]] #tag2" "b3"]
|
||||
(->> (dsl-query "(not [[page 2]])")
|
||||
;; Only filter to page1 to get meaningful results
|
||||
|
||||
Reference in New Issue
Block a user