Merge branch 'master' of github.com:seancorfield/next-jdbc

This commit is contained in:
Sean Corfield 2019-07-22 15:12:19 -07:00
commit 1b8e4b8c9c
2 changed files with 9 additions and 4 deletions

View file

@ -18,7 +18,7 @@ Although `get-datasource` does not accept options, the "db spec" hash map passed
* `:user` -- an optional string that identifies the database username to be used when authenticating, * `:user` -- an optional string that identifies the database username to be used when authenticating,
* `:password` -- an optional string that identifies the database password to be used when authenticating. * `:password` -- an optional string that identifies the database password to be used when authenticating.
Any additional keys provided in the "db spec" will be passed to the JDBC driver as `Properties` when each connection is made. Any additional keys provided in the "db spec" will be passed to the JDBC driver as `Properties` when each connection is made. Alternatively, when used with `next.jdbc.connection/->pool`, additional keys correspond to setters called on the pooled connection object.
Any path that calls `get-connection` will accept the following options: Any path that calls `get-connection` will accept the following options:
@ -56,6 +56,11 @@ Any function that creates a `PreparedStatement` will accept the following option
Not all databases or drivers support all of these options, or all values for any given option. If `:return-keys` is a vector of column names and that is not supported, `next.jdbc` will attempt a generic "return generated keys" option instead. If that is not supported, `next.jdbc` will fall back to a regular SQL operation. If other options are not supported, you may get a `SQLException`. Not all databases or drivers support all of these options, or all values for any given option. If `:return-keys` is a vector of column names and that is not supported, `next.jdbc` will attempt a generic "return generated keys" option instead. If that is not supported, `next.jdbc` will fall back to a regular SQL operation. If other options are not supported, you may get a `SQLException`.
In addition, `next.jdbc.prepare/execute-batch!` accepts an options hash map that can contain the following:
* `:batch-size` -- an integer that determines how to partition the parameter groups for submitting to the database in batches,
* `:large` -- a Boolean flag that indicates whether the batch will produce large update counts (`long` rather than `int` values).
## Transactions ## Transactions
The `transact` function and `with-transaction` macro accept the following options: The `transact` function and `with-transaction` macro accept the following options:

View file

@ -13,7 +13,7 @@ Because string-building isn't always much fun, `next.jdbc.sql` also provides som
as well as these more specific "read" operations: as well as these more specific "read" operations:
* `find-by-keys` -- a query on one or more column values, specified as a hash map, * `find-by-keys` -- a query on one or more column values, specified as a hash map or `WHERE` clause,
* `get-by-id` -- a query to return a single row, based on a single column value, usually the primary key. * `get-by-id` -- a query to return a single row, based on a single column value, usually the primary key.
These functions are described in more detail below. They are intended to cover the most common, simple SQL operations. If you need more expressiveness, consider one of the following libraries to build SQL/parameter vectors, or run queries: These functions are described in more detail below. They are intended to cover the most common, simple SQL operations. If you need more expressiveness, consider one of the following libraries to build SQL/parameter vectors, or run queries:
@ -35,7 +35,7 @@ Given a table name (as a keyword) and a hash map of column names and values, thi
## `insert-multi!` ## `insert-multi!`
Given a table name (as a keyword), a vector of column names, and a vector row values, this performs a multi-row insertion into the database: Given a table name (as a keyword), a vector of column names, and a vector of row value vectors, this performs a multi-row insertion into the database:
```clojure ```clojure
(sql/insert-multi! ds :address (sql/insert-multi! ds :address
@ -53,7 +53,7 @@ Given a table name (as a keyword), a vector of column names, and a vector row va
Note: this expands to a single SQL statement with placeholders for every Note: this expands to a single SQL statement with placeholders for every
value being inserted -- for large sets of rows, this may exceed the limits value being inserted -- for large sets of rows, this may exceed the limits
on SQL string size and/or number of parameters for your JDBC driver or your on SQL string size and/or number of parameters for your JDBC driver or your
database! database! You should look at [`next.jdbc.prepare/execute-batch!'](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT/api/next.jdbc.prepare#execute-batch!) for an alternative approach.
## `query` ## `query`