 (defprotocol ITable
   (table [_] "Table constructor"))
 
+(defprotocol IName
+  (name [_] "Name constructor"))
+
 (defprotocol ICondition
   (condition [_] "Condition constructor"))
 

(ns cljooq.dsl
  "Sql building dsl"
  (:import org.jooq.impl.DSL))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Protocols for constructors


(extend-protocol IField
  java.lang.String
  (field* [s] (DSL/field s))

  clojure.lang.Keyword
  (field* [kw] (field* (clojure.core/name kw)))

  org.jooq.Field
  (field* [f] f)

  ;; org.jooq.impl.SelectQueryAsExistsCondition
  ;; (field* [f] f)

  org.jooq.impl.Val
  (field* [v] v))

(extend-protocol ITable
  java.lang.String
  (table [s] (DSL/table s))

  clojure.lang.Keyword
  (table [kw] (table (clojure.core/name kw)))

  org.jooq.Table
  (table [t] t))

(extend-protocol IName
  java.lang.String
  (name [s]
    (-> (into-array String [s])
        (DSL/name)))

  clojure.lang.Keyword
  (name [kw] (name (clojure.core/name kw))))

(extend-protocol ICondition
  java.lang.String
