From ee2fcc47ab6f259a388a6fbf091da020b3e7c683 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Fri, 26 Apr 2019 10:34:26 -0700 Subject: [PATCH] Fixes #17 by changing sql-string to sql-params --- CHANGELOG.md | 4 ++-- doc/result-set-builders.md | 2 +- src/next/jdbc.clj | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26d278a..716dde1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -* 2019-04-24 -- 1.0.0-alpha11 -- Rename `:gen-fn` to `:builder-fn` (**BREAKING CHANGE!**); Fix #13 by adding documentation for `datafy`/`nav`/`:schema`; Fix #15 by automatically adding `:next.jdbc/sql-string` into the options hash map, so custom builders can depend on the SQL string. +* 2019-04-24 -- 1.0.0-alpha11 -- Rename `:gen-fn` to `:builder-fn` (**BREAKING CHANGE!**); Fix #13 by adding documentation for `datafy`/`nav`/`:schema`; Fix #15 by automatically adding `:next.jdbc/sql-string` (as of 1.0.0-alpha12: `:next.jdbc/sql-params`) into the options hash map, so custom builders can depend on the SQL string. * 2019-04-22 -- 1.0.0-alpha9 -- Fix #14 by respecting `:gen-fn` (as of 1.0.0-alpha11: `:builder-fn`) in `execute-one` for `PreparedStatement`. * 2019-04-21 -- 1.0.0-alpha8 -- Initial publicly announced release. @@ -8,4 +8,4 @@ The following changes have been committed to the **master** branch and will be in the next release: -* None at this time. +* Fix #17 by renaming `:next.jdbc/sql-string` to `:next.jdbc/sql-params` (**BREAKING CHANGE!**) and pass whole vector. diff --git a/doc/result-set-builders.md b/doc/result-set-builders.md index 2c2952b..7d8f497 100644 --- a/doc/result-set-builders.md +++ b/doc/result-set-builders.md @@ -42,7 +42,7 @@ The `as-*` functions described above are all implemented in terms of these proto The options hash map for any `next.jdbc` function can contain a `:builder-fn` key and the value is used at the row/result set builder function. The tests for `next.jdbc.result-set` include a [record-based builder function](https://github.com/seancorfield/next-jdbc/blob/master/test/next/jdbc/result_set_test.clj#L148-L164) as an example of how you can extend this to satisfy your needs. -The options hash map passed to the builder function will contain a `:next.jdbc/sql-string` key, whose value is the SQL string passed into the top-level `next.jdbc` functions (`reducible!`, `execute!`, and `execute-one!`). If no SQL string was passed in -- those functions were called with just a `PreparedStatement` -- then `:next.jdbc/sql-string` will have a `nil` value. +The options hash map passed to the builder function will contain a `:next.jdbc/sql-params` key, whose value is the SQL + parameters vector passed into the top-level `next.jdbc` functions (`reducible!`, `execute!`, and `execute-one!`). # ReadableColumn diff --git a/src/next/jdbc.clj b/src/next/jdbc.clj index 9a4b133..6eb90f1 100644 --- a/src/next/jdbc.clj +++ b/src/next/jdbc.clj @@ -139,10 +139,10 @@ (p/-execute stmt [] {})) ([connectable sql-params] (p/-execute connectable sql-params - {:next.jdbc/sql-string (first sql-params)})) + {:next.jdbc/sql-params sql-params})) ([connectable sql-params opts] (p/-execute connectable sql-params - (assoc opts :next.jdbc/sql-string (first sql-params))))) + (assoc opts :next.jdbc/sql-params sql-params)))) (defn execute! "General SQL execution function. @@ -155,10 +155,10 @@ (p/-execute-all stmt [] {})) ([connectable sql-params] (p/-execute-all connectable sql-params - {:next.jdbc/sql-string (first sql-params)})) + {:next.jdbc/sql-params sql-params})) ([connectable sql-params opts] (p/-execute-all connectable sql-params - (assoc opts :next.jdbc/sql-string (first sql-params))))) + (assoc opts :next.jdbc/sql-params sql-params)))) (defn execute-one! "General SQL execution function that returns just the first row of a result. @@ -169,10 +169,10 @@ (p/-execute-one stmt [] {})) ([connectable sql-params] (p/-execute-one connectable sql-params - {:next.jdbc/sql-string (first sql-params)})) + {:next.jdbc/sql-params sql-params})) ([connectable sql-params opts] (p/-execute-one connectable sql-params - (assoc opts :next.jdbc/sql-string (first sql-params))))) + (assoc opts :next.jdbc/sql-params sql-params)))) (defn transact "Given a connectable object and a function (taking a `Connection`),