Fixes #17 by changing sql-string to sql-params

This commit is contained in:
Sean Corfield 2019-04-26 10:34:26 -07:00
parent a5e8cca61b
commit ee2fcc47ab
3 changed files with 9 additions and 9 deletions

View file

@ -1,6 +1,6 @@
# Change Log # 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-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. * 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: 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.

View file

@ -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 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 # ReadableColumn

View file

@ -139,10 +139,10 @@
(p/-execute stmt [] {})) (p/-execute stmt [] {}))
([connectable sql-params] ([connectable sql-params]
(p/-execute 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] ([connectable sql-params opts]
(p/-execute connectable sql-params (p/-execute connectable sql-params
(assoc opts :next.jdbc/sql-string (first sql-params))))) (assoc opts :next.jdbc/sql-params sql-params))))
(defn execute! (defn execute!
"General SQL execution function. "General SQL execution function.
@ -155,10 +155,10 @@
(p/-execute-all stmt [] {})) (p/-execute-all stmt [] {}))
([connectable sql-params] ([connectable sql-params]
(p/-execute-all 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] ([connectable sql-params opts]
(p/-execute-all connectable sql-params (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! (defn execute-one!
"General SQL execution function that returns just the first row of a result. "General SQL execution function that returns just the first row of a result.
@ -169,10 +169,10 @@
(p/-execute-one stmt [] {})) (p/-execute-one stmt [] {}))
([connectable sql-params] ([connectable sql-params]
(p/-execute-one 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] ([connectable sql-params opts]
(p/-execute-one connectable sql-params (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 (defn transact
"Given a connectable object and a function (taking a `Connection`), "Given a connectable object and a function (taking a `Connection`),