Merge branch 'develop' into multi-rs
This commit is contained in:
commit
7f702c96fe
6 changed files with 70 additions and 57 deletions
|
|
@ -7,6 +7,9 @@ Changes made on master since 1.0.475:
|
||||||
|
|
||||||
## Stable Builds
|
## Stable Builds
|
||||||
|
|
||||||
|
* 2020-06-22 -- 1.0.476
|
||||||
|
* Extend default options behavior to `next.jdbc.sql` functions.
|
||||||
|
|
||||||
* 2020-06-22 -- 1.0.475
|
* 2020-06-22 -- 1.0.475
|
||||||
* Add tests for `"jtds"` database driver (against MS SQL Server), making it officially supported.
|
* Add tests for `"jtds"` database driver (against MS SQL Server), making it officially supported.
|
||||||
* Switch from OpenTable Embedded PostgreSQL to Zonky's version, so that testing can move forward from PostgreSQL 10.11 to 12.2.0.
|
* Switch from OpenTable Embedded PostgreSQL to Zonky's version, so that testing can move forward from PostgreSQL 10.11 to 12.2.0.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ The next generation of `clojure.java.jdbc`: a new low-level Clojure wrapper for
|
||||||
|
|
||||||
The latest versions on Clojars and on cljdoc:
|
The latest versions on Clojars and on cljdoc:
|
||||||
|
|
||||||
[](https://clojars.org/seancorfield/next.jdbc) [](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT)
|
[](https://clojars.org/seancorfield/next.jdbc) [](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT)
|
||||||
|
|
||||||
The documentation on [cljdoc.org](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT) is for the current version of `next.jdbc`:
|
The documentation on [cljdoc.org](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT) is for the current version of `next.jdbc`:
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ The documentation on [cljdoc.org](https://cljdoc.org/d/seancorfield/next.jdbc/CU
|
||||||
* [Migrating from `clojure.java.jdbc`](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT/doc/migration-from-clojure-java-jdbc)
|
* [Migrating from `clojure.java.jdbc`](https://cljdoc.org/d/seancorfield/next.jdbc/CURRENT/doc/migration-from-clojure-java-jdbc)
|
||||||
* Feedback via [issues](https://github.com/seancorfield/next-jdbc/issues) or in the [`#sql` channel on the Clojurians Slack](https://clojurians.slack.com/messages/C1Q164V29/details/) or the [`#sql` stream on the Clojurians Zulip](https://clojurians.zulipchat.com/#narrow/stream/152063-sql).
|
* Feedback via [issues](https://github.com/seancorfield/next-jdbc/issues) or in the [`#sql` channel on the Clojurians Slack](https://clojurians.slack.com/messages/C1Q164V29/details/) or the [`#sql` stream on the Clojurians Zulip](https://clojurians.zulipchat.com/#narrow/stream/152063-sql).
|
||||||
|
|
||||||
The documentation on GitHub is for **develop** since the 1.0.475 release -- [see the CHANGELOG](https://github.com/seancorfield/next-jdbc/blob/develop/CHANGELOG.md) and then read the [corresponding updated documentation](https://github.com/seancorfield/next-jdbc/tree/develop/doc) on GitHub if you want.
|
The documentation on GitHub is for **develop** since the 1.0.476 release -- [see the CHANGELOG](https://github.com/seancorfield/next-jdbc/blob/develop/CHANGELOG.md) and then read the [corresponding updated documentation](https://github.com/seancorfield/next-jdbc/tree/develop/doc) on GitHub if you want.
|
||||||
|
|
||||||
This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository.
|
This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ It is designed to work with Clojure 1.10 or later, supports `datafy`/`nav`, and
|
||||||
You can add `next.jdbc` to your project with either:
|
You can add `next.jdbc` to your project with either:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
seancorfield/next.jdbc {:mvn/version "1.0.475"}
|
seancorfield/next.jdbc {:mvn/version "1.0.476"}
|
||||||
```
|
```
|
||||||
for `deps.edn` or:
|
for `deps.edn` or:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
[seancorfield/next.jdbc "1.0.475"]
|
[seancorfield/next.jdbc "1.0.476"]
|
||||||
```
|
```
|
||||||
for `project.clj` or `build.boot`.
|
for `project.clj` or `build.boot`.
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ For the examples in this documentation, we will use a local H2 database on disk,
|
||||||
```clojure
|
```clojure
|
||||||
;; deps.edn
|
;; deps.edn
|
||||||
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
|
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
|
||||||
seancorfield/next.jdbc {:mvn/version "1.0.475"}
|
seancorfield/next.jdbc {:mvn/version "1.0.476"}
|
||||||
com.h2database/h2 {:mvn/version "1.4.199"}}}
|
com.h2database/h2 {:mvn/version "1.4.199"}}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
4
pom.xml
4
pom.xml
|
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>seancorfield</groupId>
|
<groupId>seancorfield</groupId>
|
||||||
<artifactId>next.jdbc</artifactId>
|
<artifactId>next.jdbc</artifactId>
|
||||||
<version>1.0.475</version>
|
<version>1.0.476</version>
|
||||||
<name>next.jdbc</name>
|
<name>next.jdbc</name>
|
||||||
<description>The next generation of clojure.java.jdbc: a new low-level Clojure wrapper for JDBC-based access to databases.</description>
|
<description>The next generation of clojure.java.jdbc: a new low-level Clojure wrapper for JDBC-based access to databases.</description>
|
||||||
<url>https://github.com/seancorfield/next-jdbc</url>
|
<url>https://github.com/seancorfield/next-jdbc</url>
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<url>https://github.com/seancorfield/next-jdbc</url>
|
<url>https://github.com/seancorfield/next-jdbc</url>
|
||||||
<connection>scm:git:git://github.com/seancorfield/next-jdbc.git</connection>
|
<connection>scm:git:git://github.com/seancorfield/next-jdbc.git</connection>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/seancorfield/next-jdbc.git</developerConnection>
|
<developerConnection>scm:git:ssh://git@github.com/seancorfield/next-jdbc.git</developerConnection>
|
||||||
<tag>v1.0.475</tag>
|
<tag>v1.0.476</tag>
|
||||||
</scm>
|
</scm>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,10 @@
|
||||||
([connectable table key-map]
|
([connectable table key-map]
|
||||||
(insert! connectable table key-map {}))
|
(insert! connectable table key-map {}))
|
||||||
([connectable table key-map opts]
|
([connectable table key-map opts]
|
||||||
|
(let [opts (merge (:options connectable) opts)]
|
||||||
(execute-one! connectable
|
(execute-one! connectable
|
||||||
(for-insert table key-map opts)
|
(for-insert table key-map opts)
|
||||||
(merge {:return-keys true} opts))))
|
(merge {:return-keys true} opts)))))
|
||||||
|
|
||||||
(defn insert-multi!
|
(defn insert-multi!
|
||||||
"Syntactic sugar over `execute!` to make inserting columns/rows easier.
|
"Syntactic sugar over `execute!` to make inserting columns/rows easier.
|
||||||
|
|
@ -57,9 +58,10 @@
|
||||||
(insert-multi! connectable table cols rows {}))
|
(insert-multi! connectable table cols rows {}))
|
||||||
([connectable table cols rows opts]
|
([connectable table cols rows opts]
|
||||||
(if (seq rows)
|
(if (seq rows)
|
||||||
|
(let [opts (merge (:options connectable) opts)]
|
||||||
(execute! connectable
|
(execute! connectable
|
||||||
(for-insert-multi table cols rows opts)
|
(for-insert-multi table cols rows opts)
|
||||||
(merge {:return-keys true} opts))
|
(merge {:return-keys true} opts)))
|
||||||
[])))
|
[])))
|
||||||
|
|
||||||
(defn query
|
(defn query
|
||||||
|
|
@ -70,7 +72,8 @@
|
||||||
([connectable sql-params]
|
([connectable sql-params]
|
||||||
(query connectable sql-params {}))
|
(query connectable sql-params {}))
|
||||||
([connectable sql-params opts]
|
([connectable sql-params opts]
|
||||||
(execute! connectable sql-params opts)))
|
(let [opts (merge (:options connectable) opts)]
|
||||||
|
(execute! connectable sql-params opts))))
|
||||||
|
|
||||||
(defn find-by-keys
|
(defn find-by-keys
|
||||||
"Syntactic sugar over `execute!` to make certain common queries easier.
|
"Syntactic sugar over `execute!` to make certain common queries easier.
|
||||||
|
|
@ -85,7 +88,8 @@
|
||||||
([connectable table key-map]
|
([connectable table key-map]
|
||||||
(find-by-keys connectable table key-map {}))
|
(find-by-keys connectable table key-map {}))
|
||||||
([connectable table key-map opts]
|
([connectable table key-map opts]
|
||||||
(execute! connectable (for-query table key-map opts) opts)))
|
(let [opts (merge (:options connectable) opts)]
|
||||||
|
(execute! connectable (for-query table key-map opts) opts))))
|
||||||
|
|
||||||
(defn get-by-id
|
(defn get-by-id
|
||||||
"Syntactic sugar over `execute-one!` to make certain common queries easier.
|
"Syntactic sugar over `execute-one!` to make certain common queries easier.
|
||||||
|
|
@ -100,7 +104,8 @@
|
||||||
([connectable table pk opts]
|
([connectable table pk opts]
|
||||||
(get-by-id connectable table pk :id opts))
|
(get-by-id connectable table pk :id opts))
|
||||||
([connectable table pk pk-name opts]
|
([connectable table pk pk-name opts]
|
||||||
(execute-one! connectable (for-query table {pk-name pk} opts) opts)))
|
(let [opts (merge (:options connectable) opts)]
|
||||||
|
(execute-one! connectable (for-query table {pk-name pk} opts) opts))))
|
||||||
|
|
||||||
(defn update!
|
(defn update!
|
||||||
"Syntactic sugar over `execute-one!` to make certain common updates easier.
|
"Syntactic sugar over `execute-one!` to make certain common updates easier.
|
||||||
|
|
@ -111,9 +116,10 @@
|
||||||
([connectable table key-map where-params]
|
([connectable table key-map where-params]
|
||||||
(update! connectable table key-map where-params {}))
|
(update! connectable table key-map where-params {}))
|
||||||
([connectable table key-map where-params opts]
|
([connectable table key-map where-params opts]
|
||||||
|
(let [opts (merge (:options connectable) opts)]
|
||||||
(execute-one! connectable
|
(execute-one! connectable
|
||||||
(for-update table key-map where-params opts)
|
(for-update table key-map where-params opts)
|
||||||
opts)))
|
opts))))
|
||||||
|
|
||||||
(defn delete!
|
(defn delete!
|
||||||
"Syntactic sugar over `execute-one!` to make certain common deletes easier.
|
"Syntactic sugar over `execute-one!` to make certain common deletes easier.
|
||||||
|
|
@ -124,4 +130,5 @@
|
||||||
([connectable table where-params]
|
([connectable table where-params]
|
||||||
(delete! connectable table where-params {}))
|
(delete! connectable table where-params {}))
|
||||||
([connectable table where-params opts]
|
([connectable table where-params opts]
|
||||||
(execute-one! connectable (for-delete table where-params opts) opts)))
|
(let [opts (merge (:options connectable) opts)]
|
||||||
|
(execute-one! connectable (for-delete table where-params opts) opts))))
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
(ns next.jdbc.sql-test
|
(ns next.jdbc.sql-test
|
||||||
"Tests for the syntactic sugar SQL functions."
|
"Tests for the syntactic sugar SQL functions."
|
||||||
(:require [clojure.test :refer [deftest is testing use-fixtures]]
|
(:require [clojure.test :refer [deftest is testing use-fixtures]]
|
||||||
|
[next.jdbc :as jdbc]
|
||||||
[next.jdbc.specs :as specs]
|
[next.jdbc.specs :as specs]
|
||||||
[next.jdbc.sql :as sql]
|
[next.jdbc.sql :as sql]
|
||||||
[next.jdbc.test-fixtures
|
[next.jdbc.test-fixtures
|
||||||
|
|
@ -16,8 +17,8 @@
|
||||||
(specs/instrument)
|
(specs/instrument)
|
||||||
|
|
||||||
(deftest test-query
|
(deftest test-query
|
||||||
(let [rs (sql/query (ds) ["select * from fruit order by id"]
|
(let [ds-opts (jdbc/with-options (ds) (default-options))
|
||||||
(default-options))]
|
rs (sql/query ds-opts ["select * from fruit order by id"])]
|
||||||
(is (= 4 (count rs)))
|
(is (= 4 (count rs)))
|
||||||
(is (every? map? rs))
|
(is (every? map? rs))
|
||||||
(is (every? meta rs))
|
(is (every? meta rs))
|
||||||
|
|
@ -25,45 +26,47 @@
|
||||||
(is (= 4 ((column :FRUIT/ID) (last rs))))))
|
(is (= 4 ((column :FRUIT/ID) (last rs))))))
|
||||||
|
|
||||||
(deftest test-find-by-keys
|
(deftest test-find-by-keys
|
||||||
(let [rs (sql/find-by-keys (ds) :fruit {:appearance "neon-green"})]
|
(let [ds-opts (jdbc/with-options (ds) (default-options))]
|
||||||
|
(let [rs (sql/find-by-keys ds-opts :fruit {:appearance "neon-green"})]
|
||||||
(is (vector? rs))
|
(is (vector? rs))
|
||||||
(is (= [] rs)))
|
(is (= [] rs)))
|
||||||
(let [rs (sql/find-by-keys (ds) :fruit {:appearance "yellow"}
|
(let [rs (sql/find-by-keys ds-opts :fruit {:appearance "yellow"})]
|
||||||
(default-options))]
|
|
||||||
(is (= 1 (count rs)))
|
(is (= 1 (count rs)))
|
||||||
(is (every? map? rs))
|
(is (every? map? rs))
|
||||||
(is (every? meta rs))
|
(is (every? meta rs))
|
||||||
(is (= 2 ((column :FRUIT/ID) (first rs))))))
|
(is (= 2 ((column :FRUIT/ID) (first rs)))))))
|
||||||
|
|
||||||
(deftest test-get-by-id
|
(deftest test-get-by-id
|
||||||
(is (nil? (sql/get-by-id (ds) :fruit -1)))
|
(let [ds-opts (jdbc/with-options (ds) (default-options))]
|
||||||
(let [row (sql/get-by-id (ds) :fruit 3 (default-options))]
|
(is (nil? (sql/get-by-id ds-opts :fruit -1)))
|
||||||
|
(let [row (sql/get-by-id ds-opts :fruit 3)]
|
||||||
(is (map? row))
|
(is (map? row))
|
||||||
(is (= "Peach" ((column :FRUIT/NAME) row))))
|
(is (= "Peach" ((column :FRUIT/NAME) row))))
|
||||||
(let [row (sql/get-by-id (ds) :fruit "juicy" :appearance (default-options))]
|
(let [row (sql/get-by-id ds-opts :fruit "juicy" :appearance {})]
|
||||||
(is (map? row))
|
(is (map? row))
|
||||||
(is (= 4 ((column :FRUIT/ID) row)))
|
(is (= 4 ((column :FRUIT/ID) row)))
|
||||||
(is (= "Orange" ((column :FRUIT/NAME) row))))
|
(is (= "Orange" ((column :FRUIT/NAME) row))))
|
||||||
(let [row (sql/get-by-id (ds) :fruit "Banana" :FRUIT/NAME (default-options))]
|
(let [row (sql/get-by-id ds-opts :fruit "Banana" :FRUIT/NAME {})]
|
||||||
(is (map? row))
|
(is (map? row))
|
||||||
(is (= 2 ((column :FRUIT/ID) row)))))
|
(is (= 2 ((column :FRUIT/ID) row))))))
|
||||||
|
|
||||||
(deftest test-update!
|
(deftest test-update!
|
||||||
|
(let [ds-opts (jdbc/with-options (ds) (default-options))]
|
||||||
(try
|
(try
|
||||||
(is (= {:next.jdbc/update-count 1}
|
(is (= {:next.jdbc/update-count 1}
|
||||||
(sql/update! (ds) :fruit {:appearance "brown"} {:id 2})))
|
(sql/update! ds-opts :fruit {:appearance "brown"} {:id 2})))
|
||||||
(is (= "brown" ((column :FRUIT/APPEARANCE)
|
(is (= "brown" ((column :FRUIT/APPEARANCE)
|
||||||
(sql/get-by-id (ds) :fruit 2 (default-options)))))
|
(sql/get-by-id ds-opts :fruit 2))))
|
||||||
(finally
|
(finally
|
||||||
(sql/update! (ds) :fruit {:appearance "yellow"} {:id 2})))
|
(sql/update! ds-opts :fruit {:appearance "yellow"} {:id 2})))
|
||||||
(try
|
(try
|
||||||
(is (= {:next.jdbc/update-count 1}
|
(is (= {:next.jdbc/update-count 1}
|
||||||
(sql/update! (ds) :fruit {:appearance "green"}
|
(sql/update! ds-opts :fruit {:appearance "green"}
|
||||||
["name = ?" "Banana"])))
|
["name = ?" "Banana"])))
|
||||||
(is (= "green" ((column :FRUIT/APPEARANCE)
|
(is (= "green" ((column :FRUIT/APPEARANCE)
|
||||||
(sql/get-by-id (ds) :fruit 2 (default-options)))))
|
(sql/get-by-id ds-opts :fruit 2))))
|
||||||
(finally
|
(finally
|
||||||
(sql/update! (ds) :fruit {:appearance "yellow"} {:id 2}))))
|
(sql/update! ds-opts :fruit {:appearance "yellow"} {:id 2})))))
|
||||||
|
|
||||||
(deftest test-insert-delete
|
(deftest test-insert-delete
|
||||||
(let [new-key (cond (derby?) :1
|
(let [new-key (cond (derby?) :1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue