jackrusher / mundaneum

A clojure wrapper around WikiData
BSD Zero Clause License
128 stars 16 forks source link

Breaking Changes? #16

Closed den1k closed 2 years ago

den1k commented 2 years ago

I recently upgraded to the newest version of the library and this query started breaking

(let [wd "The Matrix"]
  (mq/query
    (b/template
      [:select :distinct ?director ?directorLabel
       :where [[~(symbol (str "wd:" wd)) (wdt :director) ?director]]
       :limit 10])))

Execution error (IllegalArgumentException) at mundaneum.query/query (query.clj:7).
Key must be integer

wondering if this is a bug or the api changed

jackrusher commented 2 years ago

As per the announcement there are breaking syntax changes: https://twitter.com/jackrusher/status/1515986224921591812

The good news is that we now have support for a much larger part of SPARQL and no longer need template (and thus the backtick dep), which helps pave the way for a future CLJS version. Check out the updated examples in the README and the Clerk notebook in the notebooks folder for more info about the slightly different syntax.

den1k commented 2 years ago

That helps! Thank you, fixed the query. Here it is for reference

(defn directors [movie-title]
     (when-let [wd (some-> movie-title not-empty mq/entity)]
       (some->>
         (mq/query `{:select [?director ?directorLabel]
                     :where  [[~wd ~(mp/wdt :director) ?director]]
                     :limit  10})
         (into [] (map :directorLabel)))))