(ns clojure-sql.query (:require [clojure-sql.compiler :as c])) (def ^:private ^:dynamic *database-type* nil) (defn set-database-type! [new-type] (alter-var-root #'*database-type* (constantly new-type)) nil) (def ^:private ^:dynamic *query-deref-behaviour* #(c/compile-query *database-type* %)) (defn set-query-deref-behaviour! [f] (alter-var-root #'*query-deref-behaviour* (constantly f)) nil) (defrecord ^:private Query [] clojure.lang.IDeref (deref [this] (*query-deref-behaviour* this))) (defmethod print-method Query [query writer] (binding [*out* writer] (pr (c/compile-query nil query))))