Skip to content

Commit 61618e8

Browse files
committed
for clj and cljs
1 parent bfb3c1a commit 61618e8

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/practitest_firecracker/query_dsl.cljc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,16 @@
8383
'trim (if (= 1 (count args))
8484
(string/trim (first args))
8585
(return-error "Syntax error: 'trim' must have only one argument" query))
86-
(throw
87-
(ex-info (str "Syntax error: unsupported function: " op)
88-
{:query query}))))
86+
(return-error #?(:clj (format "Syntax error: unsupported function '%s'" op)
87+
:cljs (str "Syntax error: unsupported function: " op)) query)))
8988

90-
(defn eval-query-clj [entity-hash query]
89+
(defn eval-query-clj [entity query]
9190
(if (map? query)
9291
(let [{:keys [op args]} query
93-
args (map (partial eval-query-clj entity-hash) args)]
92+
args (map (partial eval-query-clj entity) args)]
9493
(parse-methods op args query))
9594
#?(:cljs (cond
96-
(= '?field query) entity-hash
95+
(= '?field query) entity
9796
(string/starts-with? (str query) "?") (throw
9897
(ex-info (str "Syntax error: unsupported variable " query)
9998
{:query query}))
@@ -102,9 +101,9 @@
102101
:clj (let [key (keyword (string/join (drop 1 (str query))))]
103102
(cond
104103
(or (= :test-suite-name key)
105-
(= :test-case-name key)) (:name entity-hash)
104+
(= :test-case-name key)) (:name entity)
106105
(and (not (= entity-hash nil))
107-
(contains? entity-hash key)) (key entity-hash)
106+
(contains? entity-hash key)) (key entity)
108107
(string/starts-with? (str query) "?") (str "")
109108
:else (str query))))))
110109

@@ -114,7 +113,7 @@
114113
args (map (partial eval-query entity-hash) args)]
115114
(parse-methods op args query))
116115
#?(:cljs (cond
117-
(= '?field query) entity-hash
116+
(= '?field query) val
118117
(string/starts-with? (str query) "?") (throw
119118
(ex-info (str "Syntax error: unsupported variable " query)
120119
{:query query}))

0 commit comments

Comments
 (0)