开发者

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

开发者 https://www.devze.com 2023-04-03 11:55 出处:网络
Is there a way to just generate the sql queries from ClojureQL\'s disj! conj! and update-in! functio开发者_如何学Cns, instead of executing them directly ?No, these methods are directly executing their

Is there a way to just generate the sql queries from ClojureQL's disj! conj! and update-in! functio开发者_如何学Cns, instead of executing them directly ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消