From 1720ce75025abd1f0d1db0679bb76d4a947a68bc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 23 Dec 2016 21:02:12 +0100 Subject: [PATCH] Move some implementation from format to impl ns. Fixes #18 --- src/suricatta/format.clj | 27 +-------------------------- src/suricatta/impl.clj | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/suricatta/format.clj b/src/suricatta/format.clj index dc24184..30b8ae6 100644 --- a/src/suricatta/format.clj +++ b/src/suricatta/format.clj @@ -1,4 +1,4 @@ -;; Copyright (c) 2014, Andrey Antukh +;; Copyright (c) 2014-2017 Andrey Antukh ;; All rights reserved. ;; ;; Redistribution and use in source and binary forms, with or without @@ -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] diff --git a/src/suricatta/impl.clj b/src/suricatta/impl.clj index 6e9f398..ed88bf9 100644 --- a/src/suricatta/impl.clj +++ b/src/suricatta/impl.clj @@ -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."