From 58e5d2080815aee19ee0893f8ed1b04043525c81 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 5 Sep 2019 17:47:39 +0200 Subject: [PATCH] Update to jooq 3.12.1 --- CHANGES.adoc | 4 +++- deploy.clj | 34 ++++++++++++++++++++++++++++++ deploy.sh | 36 -------------------------------- deps.edn | 38 ++++++++++++++++++++-------------- doc/content.adoc | 19 +++++++---------- pom.xml | 2 +- test/suricatta/extend_test.clj | 10 ++++----- 7 files changed, 72 insertions(+), 71 deletions(-) create mode 100644 deploy.clj delete mode 100755 deploy.sh diff --git a/CHANGES.adoc b/CHANGES.adoc index 6e8976a..dbaac9f 100644 --- a/CHANGES.adoc +++ b/CHANGES.adoc @@ -1,6 +1,6 @@ = Changelog -== 2.0.0 +== 2.0.0-SNAPSHOT Date: unreleased @@ -11,10 +11,12 @@ BREAKING CHANGES: are supported: `DataSource` instance and URL. - `cursor->lazyseq` is renamed to `cursor->seq` - New and simplfied method for add type extensions (see docs). +- Improved json and jsonb support thanks to JOOQ 3.12.1 Other changes: - Many performance improvements on standart queries. - Many performance improvements on lazy fetching. +- Update JOOQ to 3.12.1 == 1.3.1 diff --git a/deploy.clj b/deploy.clj new file mode 100644 index 0000000..b2c4071 --- /dev/null +++ b/deploy.clj @@ -0,0 +1,34 @@ +(require '[clojure.java.shell :as shell] + '[clojure.main]) +(require '[badigeon.jar] + '[badigeon.deploy]) + +(defmulti task first) + +(defmethod task "jar" + [args] + (badigeon.jar/jar 'funcool/suricatta + {:mvn/version "2.0.0-SNAPSHOT"} + {:out-path "target/suricatta.jar" + :mvn/repos '{"clojars" {:url "https://repo.clojars.org/"}} + :allow-all-dependencies? false})) + +(defmethod task "deploy" + [args] + (let [artifacts [{:file-path "target/suricatta.jar" :extension "jar"} + {:file-path "pom.xml" :extension "pom"}]] + (badigeon.deploy/deploy + 'funcool/suricatta "2.0.0-SNAPSHOT" + artifacts + {:id "clojars" :url "https://repo.clojars.org/"} + {:allow-unsigned? true}))) + + +(defmethod task :default + [args] + (task ["jar"]) + (task ["deploy"])) + +;;; Build script entrypoint. This should be the last expression. + +(task *command-line-args*) diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 79c02a9..0000000 --- a/deploy.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -if [ ! -e settings.xml ]; then - echo "No 'settings.xml' file found."; - cat < - - - clojars - username - password - - - -EOF -fi - -if [ ! -e pom.xml ]; then - echo "pom.xml file does not exit, you can generate it executing: clojure -Spom"; - exit 1; -fi - -if [ ! $1 ]; then - echo "Filename not provided." - exit 1; -fi - -if [ ! -e $1 ]; then - echo "Filename '$1' does not exists" - exit 1; -fi - -mvn -s settings.xml deploy:deploy-file -Dfile=$1 -DrepositoryId=clojars -Durl=https://clojars.org/repo -DpomFile=pom.xml - diff --git a/deps.edn b/deps.edn index 8e60042..659d18f 100644 --- a/deps.edn +++ b/deps.edn @@ -1,23 +1,29 @@ {:deps {org.clojure/clojure {:mvn/version "1.10.1"} - org.jooq/jooq {:mvn/version "3.11.11"}} + org.jooq/jooq {:mvn/version "3.12.1"}} :paths ["src"] - :aliases {:dev {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.4"} - org.clojure/tools.namespace {:mvn/version "0.3.0"} - org.postgresql/postgresql {:mvn/version "42.2.6"} - com.h2database/h2 {:mvn/version "1.4.199"} - cheshire/cheshire {:mvn/version "5.8.1"}} - :extra-paths ["test"]} - :bench {:extra-deps {seancorfield/next.jdbc {:mvn/version "1.0.1"} - criterium/criterium {:mvn/version "0.4.5"}}} + :aliases + {:dev {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.4"} + org.clojure/tools.namespace {:mvn/version "0.3.1"} + org.postgresql/postgresql {:mvn/version "42.2.6"} + com.h2database/h2 {:mvn/version "1.4.199"} + cheshire/cheshire {:mvn/version "5.9.0"}} + :extra-paths ["test"]} + :bench {:extra-deps {seancorfield/next.jdbc {:mvn/version "1.0.6"} + criterium/criterium {:mvn/version "0.4.5"}}} - :jar {:extra-deps {seancorfield/depstar {:mvn/version "RELEASE"}} - :main-opts ["-m" "hf.depstar.jar"]} + :jar {:extra-deps {seancorfield/depstar {:mvn/version "RELEASE"}} + :main-opts ["-m" "hf.depstar.jar"]} - :repl {:main-opts ["-m" "rebel-readline.main"]} - :ancient {:main-opts ["-m" "deps-ancient.deps-ancient"] - :extra-deps {deps-ancient {:mvn/version "RELEASE"}}} - :test {:main-opts ["-m" "user"]} - }} + :repl {:main-opts ["-m" "rebel-readline.main"]} + :ancient {:main-opts ["-m" "deps-ancient.deps-ancient"] + :extra-deps {deps-ancient {:mvn/version "RELEASE"}}} + :test {:main-opts ["-m" "user"]} + + :deploy {:extra-deps {badigeon/badigeon {:git/url "https://github.com/EwenG/badigeon.git" + :sha "db25a8f7053dec65afeb7fb0d1a5351dcdbe78bd" + :tag "0.0.8"}} + :main-opts ["deploy.clj"]} + }} diff --git a/doc/content.adoc b/doc/content.adoc index 55ec9e2..cba526a 100644 --- a/doc/content.adoc +++ b/doc/content.adoc @@ -26,8 +26,8 @@ Since _suricatta_ is a young project there may be some API breakage. === Install -The simplest way to use _suricatta_ in a clojure project, is by including it in the -dependency vector on your *_project.clj_* file: +The simplest way to use _suricatta_ in a clojure project, is by +including it in the dependency vector on your *_project.clj_* file: [source,clojure] ---- @@ -39,7 +39,8 @@ _Suricatta_ is only runs with *JDK >= 8* and *Clojure >= 1.5* == SQL Execution -This section explains the usage of the sql execution part of the library. +This section explains the usage of the sql execution part of the +library. === Connecting to database @@ -275,8 +276,6 @@ conversion. '[suricatta.impl :as impl] '[cheshire.core :as json]) -(import 'org.postgresql.util.PGobject) - (extend-protocol proto/IParam clojure.lang.IPersistentMap (-param [self ctx] @@ -292,15 +291,13 @@ Now let see the backward conversion example: [source, clojure] ---- (extend-protocol proto/ISQLType - PGobject + org.jooq.JSON (-convert [self] - (let [type (.getType self)] - (condp = type - "json" (json/decode (.getValue self) true))))) + (json/decode (.toString self) true))) ---- -Having defined the two way conversions, you can pass the clojure hash-map as a -value to the query and it is automatically converted. +Having defined the two way conversions, you can pass the clojure +hash-map as a value to the query and it is automatically converted. .Insert and query example using postgresql json fields. [source, clojure] diff --git a/pom.xml b/pom.xml index 299f7a2..a0dd8bb 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ org.jooq jooq - 3.11.11 + 3.12.1 diff --git a/test/suricatta/extend_test.clj b/test/suricatta/extend_test.clj index eeb14aa..9ae0f5f 100644 --- a/test/suricatta/extend_test.clj +++ b/test/suricatta/extend_test.clj @@ -36,14 +36,12 @@ MyJson (-param [self ctx] (let [qp (json/encode (.-data self))] - (impl/sql->param "{0}::json" qp)))) + (impl/sql->param "{0}::jsonb" qp)))) (extend-protocol proto/ISQLType - PGobject + org.jooq.JSONB (-convert [self] - (let [type (.getType self)] - (condp = type - "json" (json/decode (.getValue self) true))))) + (json/decode (.toString self) true))) (deftype MyArray [data]) @@ -73,7 +71,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftest inserting-json-test - (sc/execute *ctx* "create table t1 (k json)") + (sc/execute *ctx* "create table t1 (k jsonb)") (sc/execute *ctx* ["insert into t1 (k) values (?)" (myjson {:foo 1})]) (let [result (sc/fetch *ctx* ["select * from t1"])