0

Getting a seemingly bizarre problem with Datascript. For some reason when I run this query without it being wrapped in a function, everything works. But once I wrap it in a function, it returns the value for :block/content for every entity in the database. I'm confused because I haven't encountered any issues with wrapping other Datascript queries in the past. Does anyone more experienced than me with Datascript see any issues?

;; Works fine and returns the correct value
(ds/q '[:find ?block-text
        :where
        [?id :block/id "l_63xa4m1"]
        [?id :block/content ?block-text]]
      @conn)

;; Returns every value for `:block/content` in the db
(defn content-find
  [id-passed]
  (ds/q '[:find ?block-text
          :where
          [?id :block/id ?id-passed]
          [?id :block/content ?block-text]]
        @conn))
(content-find "l_63xa4m1")

EDIT: Solved over here

TomLisankie
  • 3,785
  • 7
  • 28
  • 32
  • If you x-post and found an answer somewhere else: it's perfectly fine to provide your own answer to your question on SO and accept that, if that solved your problem. – cfrick May 31 '20 at 20:09

1 Answers1

1

In your defn version you are using the query clause [?id :block/id ?id-passed]. This doesn't actually use the id-passed parameter you passed to the function.

I'm not sure how to pass parameters correctly. I believe there is an :in clause or so?

Thomas Heller
  • 3,842
  • 1
  • 9
  • 9
  • That would make sense, but I have another function that wraps a query with the same exact structure and works fine. The only difference is it's looking for the value of a different attribute. – TomLisankie May 30 '20 at 00:17
  • Solved over here: https://www.reddit.com/r/Clojure/comments/gt2s50/wrapping_datascript_query_in_a_function/ – TomLisankie May 30 '20 at 04:03