seancorfield / next-jdbc

A modern low-level Clojure wrapper for JDBC-based access to databases.
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/
Eclipse Public License 1.0
760 stars 90 forks source link

Support for named parameters #145

Closed aneilbaboo closed 3 years ago

aneilbaboo commented 3 years ago

Is your feature request related to a problem? Please describe. While ordered parameters are fine for relatively simple queries, they become unwieldy and error-prone for larger ones.

Describe the solution you'd like It would be nice to be able to provide a map instead of a vector.

Something like this:

(jdbc/execute-one! conn
  ["UPDATE user SET address = :address, plan = :plan WHERE id = :id "
    {:address "123 main st", :plan "Basic", :id 123}])
seancorfield commented 3 years ago

This is out of scope for next.jdbc (it was out of scope for clojure.java.jdbc as well). HoneySQL lets you use named parameters: it will generate positional SQL/parameters from named parameters and a hash map.

aneilbaboo commented 3 years ago

Makes sense. Thanks.