Fork me on GitHub
#datascript
<
2018-05-01
>
rnagpal15:05:08

I am using a custom clojure predicate function

rnagpal15:05:21

and my code is in a cljc file

rnagpal15:05:33

when included on clj, it works fine

rnagpal15:05:55

when included in cljs side it complains Unknown function

rnagpal15:05:13

I have given the full namespace/fn-name

rnagpal15:05:59

I see a test in test/datascript/test/query_fns.cljc in code

rnagpal15:05:18

(defn sample-query-fn [] 42)

#?(:clj
(deftest test-symbol-resolution
  (is (= 42 (d/q '[:find ?x .
                   :where [(datascript.test.query-fns/sample-query-fn) ?x]])))))

rnagpal15:05:31

Not sure why just a clj version is defined ? and not for cljs ?

rnagpal15:05:02

aah in the src/datascript/query.cljc I see

(defn- resolve-sym [sym]
  #?(:cljs nil
     :clj (when (namespace sym)
            (when-let [v (resolve sym)] @v))))
So no resolutions for cljs

rnagpal15:05:57

Just passed the function as variable and then it worked 🙂 Just like the way its done here

(testing "Returning nil from function filters out tuple from result"
      (is (= (d/q '[:find ?x
                    :in    [?in ...] ?f
                    :where [(?f ?in) ?x]]
                [1 2 3 4]
                #(when (even? %) %))
           #{[2] [4]})))