Skip to content

Commit

Permalink
Merge branch 'develop' into xtdb-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Dec 3, 2024
2 parents f43e549 + 9196b34 commit 80748a9
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-and-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions .gitpod.dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions .gitpod.yml

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

[![Clojars](https://img.shields.io/badge/clojars-com.github.seancorfield/next.jdbc_1.3.955-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALG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PAGaAsXMBLiwA8z3h0gRcsWsObuAWLJu8Awb3ZoB5T8EvS/CgBo9Y5Z8TPwXBJwlUI9Ia/yRrEZ8lID71Olrf0MiamkkL4kurDEjba+C/e2sninR0wrsH8eMTvrqIWbodjh7jyjdtCY3Aniz4jwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wNy0wN1QyMjo1ODo0NiswMjowMCgWtSoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTUtMDctMDdUMjI6NTg6NDYrMDI6MDBZSw2WAAAAAElFTkSuQmCC)](https://clojars.org/com.github.seancorfield/next.jdbc)
[![cljdoc](https://cljdoc.org/badge/com.github.seancorfield/next.jdbc?1.3.955)](https://cljdoc.org/d/com.github.seancorfield/next.jdbc/CURRENT)
[![Clojars](https://img.shields.io/badge/clojars-com.github.seancorfield/next.jdbc_1.3.967-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABjFBMVEUAAAAdCh0qDikdChwAAAAnDSY0EjM2FjUnDiYnDSYnDSYpDigyEDEEAQRGNUb///////8mDSYAAAAAAAAAAAAFAgUqEyoAAAAAAAAAAAAFAgUAAABXU1c2FjVMx+dQx+f///////9Nx+b////4/f6y4vRPt+RQtOT///9Qt+P///8oDSey4vRQr9/////3/P5hzelNx+dNx+dNx+f///8AAAAuDy0zETIAAAAoDScAAAAAAAARBREAAAAvDy40ETMwEC9gSF+Ne42ilKKuoK6Rg5B5ZXlaP1o4Gzf///9nTWZ4YncyEDF/bn/8/Pz9/P339/c1FTUlDCRRM1AbCRtlS2QyEDEuDy1gRWAxEDAzETIwEC/g4OAvDy40EjOaiZorDiq9sbzNyM3UzdQyEDE0ETMzETKflZ/UzdQ5Fzmu4fNYyuhNx+dPt+RLu9xQyOhBbo81GTuW2vCo4PJNx+c4MFE5N1lHiLFEhKQyEDGDboMzETI5Fjh5bXje2d57aHrIw8jc2NyWhJUrDioxe9o4AAAAPnRSTlMAkf+IAQj9+e7n6e31RtqAD/QAAAED+A0ZEQ8DwvkLBsmcR4aG8+cdAD6C8/MC94eP+qoTrgH+/wj1HA8eEvpXOCUAAAABYktHRA8YugDZAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wcHFjou4Z/shwAAAUpJREFUOMul0/VTwzAUB/AAwyW4y3B3h8EDNuTh7u6UDHcd8I+TbHSjWdrjju/1h77kc+3Lu5aQvyakF/r6B5wu1+DQMEBomLRtG0EpozYDCEccA4iIjIqOiY0bB5iYxHgZ4FQCpYneKmmal0aQPMOXZnUAvJhLkbpInf8NFtKCTrGImK6DJcTlDGl/BXGV6oCsrSNIYAM3aQDwl2xJYBtBB5lZAuyYgWzY3YMcNcjN2wc4EGMEFTg8+hlyfgEenygAj71Q9FBExH0wKC4p1bRTJlJWXqEAVNM05ovbXfkPAHBmAUQPAGaAsXMBLiwA8z3h0gRcsWsObuAWLJu8Awb3ZoB5T8EvS/CgBo9Y5Z8TPwXBJwlUI9Ia/yRrEZ8lID71Olrf0MiamkkL4kurDEjba+C/e2sninR0wrsH8eMTvrqIWbodjh7jyjdtCY3Aniz4jwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wNy0wN1QyMjo1ODo0NiswMjowMCgWtSoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTUtMDctMDdUMjI6NTg6NDYrMDI6MDBZSw2WAAAAAElFTkSuQmCC)](https://clojars.org/com.github.seancorfield/next.jdbc)
[![cljdoc](https://cljdoc.org/badge/com.github.seancorfield/next.jdbc?1.3.967)](https://cljdoc.org/d/com.github.seancorfield/next.jdbc/CURRENT)
[![Slack](https://img.shields.io/badge/slack-next.jdbc-orange.svg?logo=slack)](https://clojurians.slack.com/app_redirect?channel=sql)
[![Join Slack](https://img.shields.io/badge/slack-join_clojurians-orange.svg?logo=slack)](http://clojurians.net)

Expand All @@ -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.

Expand Down
30 changes: 15 additions & 15 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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}}}
6 changes: 3 additions & 3 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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"}}}
```

Expand Down
35 changes: 19 additions & 16 deletions src/next/jdbc/result_set.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)))
Expand All @@ -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))))))

Expand Down Expand Up @@ -910,7 +913,7 @@
(first sql-params)
(rest sql-params)
opts)]
(reduce-stmt stmt f init opts)))
(reduce-stmt stmt f init opts)))
r/CollFold
(coll-fold [_ n combinef reducef]
(with-open [con (p/get-connection this opts)
Expand All @@ -926,12 +929,12 @@
(first sql-params)
(rest sql-params)
opts)]
(if-let [rs (stmt->result-set stmt opts)]
(let [builder-fn (get opts :builder-fn as-maps)
builder (builder-fn rs opts)]
(when (.next rs)
(datafiable-row (row-builder builder) this opts)))
{:next.jdbc/update-count (.getUpdateCount stmt)})))
(if-let [rs (stmt->result-set stmt opts)]
(let [builder-fn (get opts :builder-fn as-maps)
builder (builder-fn rs opts)]
(when (.next rs)
(datafiable-row (row-builder builder) this opts)))
{:next.jdbc/update-count (.getUpdateCount stmt)})))
(-execute-all [this sql-params opts]
(with-open [con (p/get-connection this opts)
stmt (prepare/create con
Expand Down Expand Up @@ -982,8 +985,8 @@

java.sql.Statement
(-execute [this sql-params opts]
(assert (= 1 (count sql-params))
"Parameters cannot be provided when executing a non-prepared Statement")
(validate (= 1 (count sql-params))
"Parameters cannot be provided when executing a non-prepared Statement")
(reify
clojure.lang.IReduceInit
(reduce [_ f init]
Expand All @@ -994,8 +997,8 @@
(.getConnection this) opts))
(toString [_] "`IReduceInit` from `plan` -- missing reduction?")))
(-execute-one [this sql-params opts]
(assert (= 1 (count sql-params))
"Parameters cannot be provided when executing a non-prepared Statement")
(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)
builder (builder-fn rs opts)]
Expand All @@ -1004,8 +1007,8 @@
(.getConnection this) opts)))
{:next.jdbc/update-count (.getUpdateCount this)}))
(-execute-all [this sql-params opts]
(assert (= 1 (count sql-params))
"Parameters cannot be provided when executing a non-prepared Statement")
(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 []]
(if-let [rs (stmt->result-set-update-count
Expand Down
Loading

0 comments on commit 80748a9

Please sign in to comment.