Add regression tests for querying properties with links

These tests were fixed by f1728c48cb

Also cleaned up more of query and tests i.e. split up large fns
This commit is contained in:
Gabriel Horner
2022-02-02 17:18:56 -05:00
committed by Tienson Qin
parent 5a126027eb
commit 1df386ecca
2 changed files with 62 additions and 58 deletions

View File

@@ -141,6 +141,7 @@
l)
@vars))
;; TODO: Convert -> fns to rules
(defn ->property-query
([k v]
(->property-query k v '?v))
@@ -155,6 +156,16 @@
;; For integer pages that aren't strings
[(list 'contains? sym (str v))])]))
(defn ->page-property-query
[k v]
[['?p :block/name]
['?p :block/properties '?prop]
[(list 'get '?prop (keyword k)) '?v]
(list
'or
[(list '= '?v v)]
[(list 'contains? '?v v)])])
(defn build-query
([repo e env]
(build-query repo e (assoc env :vars (atom {})) 0))
@@ -354,15 +365,8 @@
k (string/replace (name k) "_" "-")]
(if-not (nil? v)
(let [v (text/parse-property k v)
v (if (coll? v) (first v) v)
sym '?v]
[['?p :block/name]
['?p :block/properties '?prop]
[(list 'get '?prop (keyword k)) sym]
(list
'or
[(list '= sym v)]
[(list 'contains? sym v)])])
v (if (coll? v) (first v) v)]
(->page-property-query k v))
[['?p :block/name]
['?p :block/properties '?prop]
[(list 'get '?prop (keyword k)) '?prop-v]