4
votes

According to line 54 of the 'geting-started.clj' file which ships with Datomic (under samples/seattle) I should be able to use the pull function inside a query like so:

(def pull-results (q '[:find (pull ?c [*]) :where [?c :community/name]] (db conn)))

However, in my code below I get an error: IllegalArgumentException Argument [*] in :find is not a variable datomic.query/validate-query (query.clj:315)

(defn get-tag [] (d/q '[:find (d/pull ?e [*])
                        :where [?e :tag.tag/term]] (db conn)))

Now, to my eyes these two are similarly constructed. Coupled with the fact that the pull function api as read from http://docs.datomic.com/clojure/#datomic.api/pull appears to be:

(pull db pattern eid)

I would say that the API has changed since the Seattle code was written. Am I correct? If not, what is going on here. Thanks

1
remove the d/ from d/pull is my guess. It's syntax in this case. - ClojureMostly
thanks! that fixed it. - Zuriar

1 Answers

6
votes

As the commenter points out, the issue is passing the datomic.api/pull function instead of using a pull expression. Some points of clarification:

You're not invoking the pull function inside of query, but using a special expression called the pull expression inside a find clause. Note that query accepts a data structure literal (why you have to use quote/'). The pull expression is part of the query grammar and something the datalog parser recognizes, not a direct invocation of the pull function in the Datomic API which has a different invocation.