            org.jooq.SelectJoinStep
            org.jooq.InsertReturningStep
            org.jooq.Row
+           org.jooq.TableLike
+           org.jooq.FieldLike
+           org.jooq.Field
+           org.jooq.Select
            org.jooq.impl.DSL
            org.jooq.impl.DefaultConfiguration
            org.jooq.impl.DefaultDataType

(defn val
  [v]
  (-val v))

(defn table
  "Create a table instance."
  [data & [{:keys [alias] :as opts}]]
  (defer
    (let [f (-table data)]
      (if alias
        (.as f (clojure.core/name alias))
        f))))

(defn select
  "Start select statement."


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

  clojure.lang.IPersistentList
  (-table [pv]
    (let [[tname talias] pv
          talias (clojure.core/name talias)]
      (-> (-table tname)
          (.as talias))))

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

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