Skip to content
Snippets Groups Projects
Commit 0e339238 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

remove stray `replace-params` code. we are going to tackle that at a later time.

parent 445c0340
Branches
Tags
No related merge requests found
......@@ -298,35 +298,12 @@
(apply-clauses driver (k/select* entity) inner-query)))
(def ^:private formatter (tf/formatter "YYYY-MM-dd" (t/default-time-zone)))
;; TODO: we may need to make this part of ISQLDriver interface and let other dbs override as needed
;; Boolean, Long, Double, String, Timestamp
(defn- sql-param
"Format a single value properly for inclusion in a SQL statement"
[param]
;; TODO: we need to handle sql date/time/timestamp values here (do actual jdbc drivers have functions for this?)
(cond
(u/is-temporal? param) (str "'" (tf/unparse formatter (tc/from-sql-time param)) "'")
(string? param) (str "'" param "'")
:else (str param)))
(defn- replace-params
"Replace any positional parameters in a SQL statement `?` with a value from a list of parameters.
e.g. SELECT * FROM mytable WHERE id = ?, [1] -> SELECT * FROM mytable WHERE id = 1"
[sql params]
(if (empty? params) sql
(let [param (first params)
new-str (s/replace-first sql #"\?" (sql-param param))]
(replace-params new-str (rest params)))))
(defn mbql->native
"Transpile MBQL query into a native SQL statement."
[driver {{:keys [source-table]} :query, database :database, :as outer-query}]
(let [entity ((resolve 'metabase.driver.generic-sql/korma-entity) database source-table)
korma-form (build-korma-form driver outer-query entity)
form-with-sql (kengine/bind-query korma-form (kengine/->sql korma-form))]
;; (replace-params (:sql-str form-with-sql) (:params form-with-sql))
{:query (:sql-str form-with-sql)
:params (:params form-with-sql)}))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment