summaryrefslogtreecommitdiff
path: root/src/clojure_sql/core.clj
blob: bd4b431fa6341c9eab1b76247c00f0e92eef1a25 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(ns clojure-sql.core
  (:refer-clojure :exclude [sort])
  (:require [clojure.set :as set]
            [clojure-sql.compiler :as c]
            [clojure-sql.dsl :as d]
            [clojure-sql.query :as q]
            [clojure-sql.util :as u]
            [clojure.walk]))

(def ^:private ^:dynamic *database-type* nil)
(defn set-database-type! [new-type]
  (alter-var-root #'*database-type* (constantly new-type))
  nil)

(q/set-query-deref-behaviour! #(c/compile *database-type* %))
(defmethod print-method clojure_sql.query.Query [query writer]
  (binding [*out* writer]
    (pr (c/compile nil query))))


(def table #'d/table)
(def project #'d/project)
(def rename #'d/rename)
(def join #'d/join)
(def select #'d/select)
(def group #'d/group)
(def having #'d/having)
(def sort #'d/sort)


(-> (table :x)
    (select `($ (- :a) #"bloo")))