Merge branch 'develop' into xtdb-testing
This commit is contained in:
commit
80748a9593
12 changed files with 60 additions and 76 deletions
2
.github/workflows/test-and-release.yml
vendored
2
.github/workflows/test-and-release.yml
vendored
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
- name: Setup Clojure
|
||||
uses: DeLaGuardo/setup-clojure@master
|
||||
with:
|
||||
cli: '1.12.0.1479'
|
||||
cli: '1.12.0.1488'
|
||||
- name: Cache All The Things
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
|
|
|
|||
4
.github/workflows/test-and-snapshot.yml
vendored
4
.github/workflows/test-and-snapshot.yml
vendored
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
- name: Setup Clojure
|
||||
uses: DeLaGuardo/setup-clojure@master
|
||||
with:
|
||||
cli: '1.12.0.1479'
|
||||
cli: '1.12.0.1488'
|
||||
- name: Cache All The Things
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
|
|
@ -64,7 +64,7 @@ jobs:
|
|||
- name: Setup Clojure
|
||||
uses: DeLaGuardo/setup-clojure@master
|
||||
with:
|
||||
cli: '1.12.0.1479'
|
||||
cli: '1.12.0.1488'
|
||||
- name: Cache All The Things
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
|
|
|
|||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
- name: Setup Clojure
|
||||
uses: DeLaGuardo/setup-clojure@master
|
||||
with:
|
||||
cli: '1.12.0.1479'
|
||||
cli: '1.12.0.1488'
|
||||
- name: Cache All The Things
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
FROM gitpod/workspace-full
|
||||
|
||||
RUN brew install clojure/tools/clojure@1.12.0.1479
|
||||
23
.gitpod.yml
23
.gitpod.yml
|
|
@ -1,23 +0,0 @@
|
|||
image:
|
||||
file: .gitpod.dockerfile
|
||||
|
||||
vscode:
|
||||
extensions:
|
||||
- betterthantomorrow.calva
|
||||
- mauricioszabo.clover
|
||||
|
||||
tasks:
|
||||
- name: Prepare deps/clover
|
||||
init: |
|
||||
clojure -A:test -P
|
||||
echo 50505 > .socket-repl-port
|
||||
mkdir ~/.config/clover
|
||||
cp .clover/config.cljs ~/.config/clover/
|
||||
- name: Start REPL
|
||||
command: clojure -J-Dclojure.server.repl="{:address \"0.0.0.0\" :port 50505 :accept clojure.core.server/repl}" -A:test
|
||||
- name: See Changes
|
||||
command: code CHANGELOG.md
|
||||
|
||||
github:
|
||||
prebuilds:
|
||||
develop: true
|
||||
|
|
@ -3,16 +3,20 @@
|
|||
Only accretive/fixative changes will be made from now on.
|
||||
|
||||
* 1.3.next in progress
|
||||
* Update dev/test dependencies.
|
||||
|
||||
* 1.3.967 -- 2024-12-02
|
||||
* Address [#288](https://github.com/seancorfield/next-jdbc/issues/288) by adding speculative support for `:dbtype "xtdb"`.
|
||||
* Fix [#287](https://github.com/seancorfield/next-jdbc/issues/287) by merging user-supplied options over `:return-keys true`.
|
||||
* Fix [#282](https://github.com/seancorfield/next-jdbc/issues/282) by tracking raw `Connection` objects for active TXs, which relaxes several of the conditions around nested transactions.
|
||||
* Replace `assert` calls with proper validation, throwing `IllegalArgumentException` on failure.
|
||||
* Removed (experimental) `:name-fn` option since the driver for it no longer exists (qualified columns names in XTDB).
|
||||
|
||||
* 1.3.955 -- 2024-10-06
|
||||
* Address [#285](https://github.com/seancorfield/next-jdbc/issues/285) by setting the default Clojure version to the earliest supported (1.10.3) to give a better hint to users.
|
||||
* Update PostgreSQL **Tips & Tricks** example code to fix possible NPE. PR [#284](https://github.com/seancorfield/next-jdbc/pull/284) from [@ExNexu](https://github.com/ExNexu).
|
||||
* Address [#283](https://github.com/seancorfield/next-jdbc/issues/283) by adding a note in the documentation, linking to the PostgreSQL bug report about `ANY(array)`.
|
||||
* ~Address [#269](https://github.com/seancorfield/next-jdbc/issues/269) by adding `:name-fn` as an option (primarily for the SQL builder functions, but also for result set processing); the default is `clojure.core/name` but you can now use `next.jdbc.sql.builder/qualified-name` to preserve the qualifier.~ _[This was remove in 1.3.next since XTDB no longer supports qualified column names]_
|
||||
* ~Address [#269](https://github.com/seancorfield/next-jdbc/issues/269) by adding `:name-fn` as an option (primarily for the SQL builder functions, but also for result set processing); the default is `clojure.core/name` but you can now use `next.jdbc.sql.builder/qualified-name` to preserve the qualifier.~ _[This was removed in 1.3.967 since XTDB no longer supports qualified column names]_
|
||||
* Update testing deps; `docker-compose` => `docker compose`.
|
||||
|
||||
* 1.3.939 -- 2024-05-17
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ The next generation of `clojure.java.jdbc`: a new low-level Clojure wrapper for
|
|||
|
||||
The latest versions on Clojars and on cljdoc:
|
||||
|
||||
[](https://clojars.org/com.github.seancorfield/next.jdbc)
|
||||
[](https://cljdoc.org/d/com.github.seancorfield/next.jdbc/CURRENT)
|
||||
[](https://clojars.org/com.github.seancorfield/next.jdbc)
|
||||
[](https://cljdoc.org/d/com.github.seancorfield/next.jdbc/CURRENT)
|
||||
[](https://clojurians.slack.com/app_redirect?channel=sql)
|
||||
[](http://clojurians.net)
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ The documentation on [cljdoc.org](https://cljdoc.org/d/com.github.seancorfield/n
|
|||
* [Migrating from `clojure.java.jdbc`](https://cljdoc.org/d/com.github.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/) 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.3.955 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. Older versions of `next.jdbc` were published under the `seancorfield` group ID and you can find [older seancorfield/next.jdbc documentation on cljdoc.org](https://cljdoc.org/versions/seancorfield/next.jdbc).
|
||||
The documentation on GitHub is for **develop** since the 1.3.967 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. Older versions of `next.jdbc` were published under the `seancorfield` group ID and you can find [older seancorfield/next.jdbc documentation on cljdoc.org](https://cljdoc.org/versions/seancorfield/next.jdbc).
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
|||
30
deps.edn
30
deps.edn
|
|
@ -7,7 +7,7 @@
|
|||
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}}
|
||||
:aliases
|
||||
{;; for help: clojure -A:deps -T:build help/doc
|
||||
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.5"}
|
||||
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.6"}
|
||||
slipset/deps-deploy {:mvn/version "0.2.2"}}
|
||||
:ns-default build}
|
||||
|
||||
|
|
@ -22,33 +22,33 @@
|
|||
io.github.cognitect-labs/test-runner
|
||||
{:git/tag "v0.5.1" :git/sha "dfb30dd"}
|
||||
;; connection pooling
|
||||
com.zaxxer/HikariCP {:mvn/version "6.0.0"}
|
||||
com.zaxxer/HikariCP {:mvn/version "6.2.1"}
|
||||
com.mchange/c3p0 {:mvn/version "0.10.1"}
|
||||
;; JDBC drivers
|
||||
;; 10.16.x is JDK17+
|
||||
org.apache.derby/derby {:mvn/version "10.15.2.0"}
|
||||
org.apache.derby/derbyshared {:mvn/version "10.15.2.0"}
|
||||
org.hsqldb/hsqldb {:mvn/version "2.7.3"}
|
||||
org.hsqldb/hsqldb {:mvn/version "2.7.4"}
|
||||
com.h2database/h2 {:mvn/version "2.3.232"}
|
||||
net.sourceforge.jtds/jtds {:mvn/version "1.3.1"}
|
||||
org.mariadb.jdbc/mariadb-java-client {:mvn/version "3.4.1"}
|
||||
com.mysql/mysql-connector-j {:mvn/version "9.0.0"}
|
||||
org.mariadb.jdbc/mariadb-java-client {:mvn/version "3.5.1"}
|
||||
com.mysql/mysql-connector-j {:mvn/version "9.1.0"}
|
||||
;; 42.7.4 changes update count (to -1) for stored procs:
|
||||
org.postgresql/postgresql {:mvn/version "42.7.4"}
|
||||
io.zonky.test/embedded-postgres {:mvn/version "2.0.7"}
|
||||
io.zonky.test.postgres/embedded-postgres-binaries-darwin-amd64 {:mvn/version "17.0.0"}
|
||||
io.zonky.test.postgres/embedded-postgres-binaries-linux-amd64 {:mvn/version "17.0.0"}
|
||||
io.zonky.test.postgres/embedded-postgres-binaries-windows-amd64 {:mvn/version "17.0.0"}
|
||||
org.xerial/sqlite-jdbc {:mvn/version "3.46.1.3"}
|
||||
io.zonky.test/embedded-postgres {:mvn/version "2.1.0"}
|
||||
io.zonky.test.postgres/embedded-postgres-binaries-darwin-amd64 {:mvn/version "17.2.0"}
|
||||
io.zonky.test.postgres/embedded-postgres-binaries-linux-amd64 {:mvn/version "17.2.0"}
|
||||
io.zonky.test.postgres/embedded-postgres-binaries-windows-amd64 {:mvn/version "17.2.0"}
|
||||
org.xerial/sqlite-jdbc {:mvn/version "3.47.1.0"}
|
||||
com.microsoft.sqlserver/mssql-jdbc {:mvn/version "12.8.1.jre11"}
|
||||
;; prerelease XTDB JDBC module:
|
||||
com.xtdb/xtdb-jdbc {:mvn/version "2.0.0-SNAPSHOT"}
|
||||
;; use log4j2 to reduce log noise during testing:
|
||||
org.apache.logging.log4j/log4j-api {:mvn/version "2.24.0"}
|
||||
org.apache.logging.log4j/log4j-api {:mvn/version "2.24.2"}
|
||||
;; bridge everything into log4j:
|
||||
org.apache.logging.log4j/log4j-1.2-api {:mvn/version "2.24.0"}
|
||||
org.apache.logging.log4j/log4j-jcl {:mvn/version "2.24.0"}
|
||||
org.apache.logging.log4j/log4j-jul {:mvn/version "2.24.0"}
|
||||
org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.24.0"}}
|
||||
org.apache.logging.log4j/log4j-1.2-api {:mvn/version "2.24.2"}
|
||||
org.apache.logging.log4j/log4j-jcl {:mvn/version "2.24.2"}
|
||||
org.apache.logging.log4j/log4j-jul {:mvn/version "2.24.2"}
|
||||
org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.24.2"}}
|
||||
:jvm-opts ["-Dlog4j2.configurationFile=log4j2-info.properties"]
|
||||
:exec-fn cognitect.test-runner.api/test}}}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,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:
|
||||
|
||||
```clojure
|
||||
com.github.seancorfield/next.jdbc {:mvn/version "1.3.955"}
|
||||
com.github.seancorfield/next.jdbc {:mvn/version "1.3.967"}
|
||||
```
|
||||
for `deps.edn` or:
|
||||
|
||||
```clojure
|
||||
[com.github.seancorfield/next.jdbc "1.3.955"]
|
||||
[com.github.seancorfield/next.jdbc "1.3.967"]
|
||||
```
|
||||
for `project.clj` or `build.boot`.
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ For the examples in this documentation, we will use a local H2 database on disk,
|
|||
```clojure
|
||||
;; deps.edn
|
||||
{:deps {org.clojure/clojure {:mvn/version "1.12.0"}
|
||||
com.github.seancorfield/next.jdbc {:mvn/version "1.3.955"}
|
||||
com.github.seancorfield/next.jdbc {:mvn/version "1.3.967"}
|
||||
com.h2database/h2 {:mvn/version "2.2.224"}}}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@
|
|||
(mapv (fn [^Integer i] (keyword (.getColumnLabel rsmeta i)))
|
||||
(range 1 (inc (if rsmeta (.getColumnCount rsmeta) 0)))))
|
||||
|
||||
(defn- validate [expr ^String msg]
|
||||
(when-not expr (throw (IllegalArgumentException. msg))))
|
||||
|
||||
(defn get-modified-column-names
|
||||
"Given `ResultSetMetaData`, return a vector of modified column names, each
|
||||
qualified by the table from which it came.
|
||||
|
|
@ -66,8 +69,8 @@
|
|||
[^ResultSetMetaData rsmeta opts]
|
||||
(let [qf (:qualifier-fn opts)
|
||||
lf (:label-fn opts)]
|
||||
(assert qf ":qualifier-fn is required")
|
||||
(assert lf ":label-fn is required")
|
||||
(validate qf ":qualifier-fn is required")
|
||||
(validate lf ":label-fn is required")
|
||||
(mapv (fn [^Integer i]
|
||||
(if-let [q (some-> (get-table-name rsmeta i) (qf) (not-empty))]
|
||||
(keyword q (-> (.getColumnLabel rsmeta i) (lf)))
|
||||
|
|
@ -81,7 +84,7 @@
|
|||
Requires the `:label-fn` option."
|
||||
[^ResultSetMetaData rsmeta opts]
|
||||
(let [lf (:label-fn opts)]
|
||||
(assert lf ":label-fn is required")
|
||||
(validate lf ":label-fn is required")
|
||||
(mapv (fn [^Integer i] (keyword (lf (.getColumnLabel rsmeta i))))
|
||||
(range 1 (inc (if rsmeta (.getColumnCount rsmeta) 0))))))
|
||||
|
||||
|
|
@ -982,7 +985,7 @@
|
|||
|
||||
java.sql.Statement
|
||||
(-execute [this sql-params opts]
|
||||
(assert (= 1 (count sql-params))
|
||||
(validate (= 1 (count sql-params))
|
||||
"Parameters cannot be provided when executing a non-prepared Statement")
|
||||
(reify
|
||||
clojure.lang.IReduceInit
|
||||
|
|
@ -994,7 +997,7 @@
|
|||
(.getConnection this) opts))
|
||||
(toString [_] "`IReduceInit` from `plan` -- missing reduction?")))
|
||||
(-execute-one [this sql-params opts]
|
||||
(assert (= 1 (count sql-params))
|
||||
(validate (= 1 (count sql-params))
|
||||
"Parameters cannot be provided when executing a non-prepared Statement")
|
||||
(if-let [rs (stmt-sql->result-set this (first sql-params))]
|
||||
(let [builder-fn (get opts :builder-fn as-maps)
|
||||
|
|
@ -1004,7 +1007,7 @@
|
|||
(.getConnection this) opts)))
|
||||
{:next.jdbc/update-count (.getUpdateCount this)}))
|
||||
(-execute-all [this sql-params opts]
|
||||
(assert (= 1 (count sql-params))
|
||||
(validate (= 1 (count sql-params))
|
||||
"Parameters cannot be provided when executing a non-prepared Statement")
|
||||
(if (:multi-rs opts)
|
||||
(loop [go (.execute this (first sql-params)) acc []]
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@
|
|||
[key-map opts]
|
||||
(as-cols (keys key-map) opts))
|
||||
|
||||
(defn- validate [expr ^String msg]
|
||||
(when-not expr (throw (IllegalArgumentException. msg))))
|
||||
|
||||
(defn by-keys
|
||||
"Given a hash map of column names and values and a clause type
|
||||
(`:set`, `:where`), return a vector of a SQL clause and its parameters.
|
||||
|
|
@ -84,7 +87,7 @@
|
|||
[(conj conds (str e " = ?")) (conj params v)])))
|
||||
[[] []]
|
||||
key-map)]
|
||||
(assert (seq where) "key-map may not be empty")
|
||||
(validate (seq where) "key-map may not be empty")
|
||||
(into [(str (str/upper-case (safe-name clause)) " "
|
||||
(str/join (if (= :where clause) " AND " ", ") where))]
|
||||
params)))
|
||||
|
|
@ -122,7 +125,7 @@
|
|||
(let [entity-fn (:table-fn opts identity)
|
||||
params (as-keys key-map opts)
|
||||
places (as-? key-map opts)]
|
||||
(assert (seq key-map) "key-map may not be empty")
|
||||
(validate (seq key-map) "key-map may not be empty")
|
||||
(into [(str "INSERT INTO " (entity-fn (safe-name table))
|
||||
" (" params ")"
|
||||
" VALUES (" places ")"
|
||||
|
|
@ -144,11 +147,11 @@
|
|||
If `:suffix` is provided in `opts`, that string is appended to the
|
||||
`INSERT ...` statement."
|
||||
[table cols rows opts]
|
||||
(assert (apply = (count cols) (map count rows))
|
||||
(validate (apply = (count cols) (map count rows))
|
||||
"column counts are not consistent across cols and rows")
|
||||
;; to avoid generating bad SQL
|
||||
(assert (seq cols) "cols may not be empty")
|
||||
(assert (seq rows) "rows may not be empty")
|
||||
(validate (seq cols) "cols may not be empty")
|
||||
(validate (seq rows) "rows may not be empty")
|
||||
(let [table-fn (:table-fn opts identity)
|
||||
batch? (:batch opts)
|
||||
params (as-cols cols opts)
|
||||
|
|
@ -195,7 +198,7 @@
|
|||
[order-by opts]
|
||||
(when-not (vector? order-by)
|
||||
(throw (IllegalArgumentException. ":order-by must be a vector")))
|
||||
(assert (seq order-by) ":order-by may not be empty")
|
||||
(validate (seq order-by) ":order-by may not be empty")
|
||||
(str "ORDER BY "
|
||||
(str/join ", " (map #(for-order-col % opts) order-by))))
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@
|
|||
|
||||
(deftest test-for-update
|
||||
(testing "empty example (would be a SQL error)"
|
||||
(is (thrown? AssertionError ; changed in #44
|
||||
(is (thrown? IllegalArgumentException
|
||||
(builder/for-update :user
|
||||
{:status 42}
|
||||
{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue