metabase / toucan

A classy high-level Clojure library for defining application models and retrieving them from a DB
Eclipse Public License 1.0
570 stars 49 forks source link

Params in query call possible ? #75

Open olymk2 opened 4 years ago

olymk2 commented 4 years ago

I have been looking at the code here https://github.com/metabase/toucan/blob/e8fbd6dde8452f72ae9adb1c8b1dd3ca757e3129/src/toucan/db.clj#L284 from what I can tell query does not take :params to pass in parameters ? or else I am not understanding whats going on.

Tried a few things like

(db/query honey-sql-query :search "text")

But this does not work, the doc string says it takes a honey sql form which i Take it is just the hash map form before its passed to sql/format which has a :params keyword to allow you to injected name params into your query.

@camsaul is this possible am i missing something, or would toucan need to be extended to allow for this ?

olymk2 commented 4 years ago

I have worked around it using the code below, by calling jdbc directly if this is not possible I may attempt a PR if that's of interest ?

  (jdbc/query (db/connection) 
              (sql/format   query
                            :params {:search "text"}))