5

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

2
  • 1
    remove the d/ from d/pull is my guess. It's syntax in this case. Commented Apr 5, 2016 at 11:50
  • thanks! that fixed it. Commented Apr 5, 2016 at 13:56

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.