Skip to content

Commit

Permalink
Move some implementation from format to impl ns.
Browse files Browse the repository at this point in the history
Fixes #18
  • Loading branch information
niwinz committed Dec 25, 2016
1 parent b860525 commit 1720ce7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
27 changes: 1 addition & 26 deletions src/suricatta/format.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; Copyright (c) 2014, Andrey Antukh <[email protected]>
;; Copyright (c) 2014-2017 Andrey Antukh <[email protected]>
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -33,31 +33,6 @@
org.jooq.impl.DefaultConfiguration
org.jooq.impl.DSL))

(extend-protocol proto/IRenderer
org.jooq.Query
(-sql [q type dialect]
(let [^Configuration conf (DefaultConfiguration.)
^DSLContext context (DSL/using conf)]
(when dialect
(.set conf (impl/translate-dialect dialect)))
(condp = type
nil (.render context q)
:named (.renderNamedParams context q)
:indexed (.render context q)
:inlined (.renderInlined context q))))

(-bind-values [q]
(let [^Configuration conf (DefaultConfiguration.)
^DSLContext context (DSL/using conf)]
(into [] (.extractBindValues context q))))

suricatta.types.Deferred
(-sql [self type dialect]
(proto/-sql @self type dialect))

(-bind-values [self]
(proto/-bind-values @self)))

(defn sql
"Renders a query sql into string."
([q]
Expand Down
25 changes: 25 additions & 0 deletions src/suricatta/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,31 @@
(bind [_ value ^BindContext ctx]
(proto/-bind value ctx))))

(extend-protocol proto/IRenderer
org.jooq.Query
(-sql [q type dialect]
(let [^Configuration conf (DefaultConfiguration.)
^DSLContext context (DSL/using conf)]
(when dialect
(.set conf (translate-dialect dialect)))
(condp = type
nil (.render context q)
:named (.renderNamedParams context q)
:indexed (.render context q)
:inlined (.renderInlined context q))))

(-bind-values [q]
(let [^Configuration conf (DefaultConfiguration.)
^DSLContext context (DSL/using conf)]
(into [] (.extractBindValues context q))))

suricatta.types.Deferred
(-sql [self type dialect]
(proto/-sql @self type dialect))

(-bind-values [self]
(proto/-bind-values @self)))

(defn make-param-impl
"Wraps a value that implements IParamType
protocol in valid jOOQ Param implementation."
Expand Down

0 comments on commit 1720ce7

Please sign in to comment.