Skip to content

Commit

Permalink
Update to jooq 3.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Sep 5, 2019
1 parent 80ef2df commit 58e5d20
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 71 deletions.
4 changes: 3 additions & 1 deletion CHANGES.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Changelog

== 2.0.0
== 2.0.0-SNAPSHOT

Date: unreleased

Expand All @@ -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
Expand Down
34 changes: 34 additions & 0 deletions deploy.clj
Original file line number Diff line number Diff line change
@@ -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*)
36 changes: 0 additions & 36 deletions deploy.sh

This file was deleted.

38 changes: 22 additions & 16 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -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"]}
}}



19 changes: 8 additions & 11 deletions doc/content.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.11.11</version>
<version>3.12.1</version>
</dependency>
</dependencies>
</project>
10 changes: 4 additions & 6 deletions test/suricatta/extend_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit 58e5d20

Please sign in to comment.