NielsK
NielsK

Reputation: 6956

Just generate SQL from ClojureQL's disj! conj! and update-in! functions

Is there a way to just generate the sql queries from ClojureQL's disj! conj! and update-in! functions, instead of executing them directly ?

Upvotes: 3

Views: 237

Answers (1)

Nicolas Buduroi
Nicolas Buduroi

Reputation: 3584

No, these methods are directly executing their respective prepared statements. They are all pretty basic. For conj! and update-in!, look at format call in the conj-rows and update-vals functions that you can find inside the internal namespace:

 (format "INSERT INTO %s %s VALUES (%s)"
         (to-tablename table) columns template)

 (format "UPDATE %s SET %s WHERE %s"
         (to-tablename table) columns where)

For disj!, ClojureQL is using the clojure.java.jdbc library delete-rows function which contains:

  (format "DELETE FROM %s WHERE %s"
          (as-identifier table) where)

So basically disj! get the ability to use java.jdbc's with-naming-strategy and with-quoted-identifiers macros for the table name while the other don't.

Upvotes: 1

Related Questions