mirror of
https://github.com/logseq/logseq.git
synced 2026-04-30 08:56:29 +00:00
fix: :and ref query should return nodes that having at least one ref (#12085)
This commit also adds a new :self-ref rule. `[[page]]` will uses :self-ref, `(or [[page1]] [[page2]])` will be `(or [:self-ref page1] [:self-ref page2]`. `(and [[page1]] [[page2]])` will be `(and [:page-ref page1] [:page-ref page2] (or [:self-ref page1] [:self-ref page2]))` to ensure the query result nodes to have at least one page reference.
This commit is contained in:
@@ -598,6 +598,7 @@ prop-d:: [[nada]]"}])
|
||||
:file/content "foo:: bar
|
||||
- b1 [[page 1]] [[tag2]]
|
||||
- b2 [[page 2]] [[tag1]]
|
||||
- b4 [[page 4]] [[tag4]]
|
||||
- b3"}])
|
||||
|
||||
(testing "page-ref queries"
|
||||
@@ -625,9 +626,16 @@ prop-d:: [[nada]]"}])
|
||||
(dsl-query "(or [[tag2]] [[page 2]])")))
|
||||
"OR query")
|
||||
|
||||
(comment
|
||||
;; FIXME: load-test-files doesn't save `b4` to the db when DB_GRAPH=1
|
||||
(is (= ["b1" "b4"]
|
||||
(map testable-content
|
||||
(dsl-query "(or [[tag2]] [[page 4]])")))
|
||||
"OR query"))
|
||||
|
||||
(is (= ["b1"]
|
||||
(map testable-content
|
||||
(dsl-query "(or [[tag2]] [[page 3]])")))
|
||||
(dsl-query "(or [[tag2]] [[page not exists]])")))
|
||||
"OR query with nonexistent page should return meaningful results")
|
||||
|
||||
(is (= (if js/process.env.DB_GRAPH #{"b1" "bar" "b3"} #{"b1" "foo:: bar" "b3"})
|
||||
|
||||
Reference in New Issue
Block a user