From 5424353f2d7b5136aaf31360f119e10c5e509591 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Wed, 24 Jul 2019 22:49:24 -0700 Subject: [PATCH] Clarify position on default options I.e., write your own wrapper if you want to globally override options. --- doc/migration-from-clojure-java-jdbc.md | 2 ++ src/next/jdbc/sql.clj | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/migration-from-clojure-java-jdbc.md b/doc/migration-from-clojure-java-jdbc.md index 58b2d7b..30a00ac 100644 --- a/doc/migration-from-clojure-java-jdbc.md +++ b/doc/migration-from-clojure-java-jdbc.md @@ -20,6 +20,8 @@ Because `clojure.java.jdbc` focuses on a hash map for the `db-spec` that is pass In [All The Options](doc/all-the-options.md), the appropriate options are shown for each function, as well as which options _will_ get passed down the call chain, e.g., if a function can open a connection, it will accept options for `get-connection`; if a function can build a result set, it will accept `:builder-fn`. However, `get-datasource`, `get-connection`, and `prepare` cannot propagate options any further because they produce Java objects as their results -- in particular, `prepare` can't accept `:builder-fn` because it doesn't build result sets: only `plan`, `execute-one!`, and `execute!` can use `:builder-fn`. +In particular, this means that you can't globally override the default options (as you could with `clojure.java.jdbc` by adding your preferred defaults to the db-spec itself). If the default options do not suit your usage and you really don't want to override them in every call, it is recommended that you provide a wrapper namespace that implements the subset of the dozen API functions (from `next.jdbc` and `next.jdbc.sql` that you want to use), overriding their `opts` argument with your defaults. + ## Primary API `next.jdbc` has a deliberately narrow primary API that has (almost) no direct overlap with `clojure.java.jdbc`: diff --git a/src/next/jdbc/sql.clj b/src/next/jdbc/sql.clj index d58a867..272e0aa 100644 --- a/src/next/jdbc/sql.clj +++ b/src/next/jdbc/sql.clj @@ -5,7 +5,9 @@ providing some syntactic sugar over `execute!`/`execute-one!`. This is intended to provide a minimal level of parity with - `clojure.java.jdbc` (`insert!`, `update!`, `delete!`, etc). + `clojure.java.jdbc` (`insert!`, `insert-multi!`, `query`, `find-by-keys`, + `get-by-id`, `update!`, and `delete!`). + For anything more complex, use a library like HoneySQL https://github.com/jkk/honeysql to generate SQL + parameters.