diff --git a/src/metabase/driver/generic_sql.clj b/src/metabase/driver/generic_sql.clj index f796639ca506eaaec16529d50fb9e7fd6943613a..103e673651eab86605f2f5f9a3949717d0a77004 100644 --- a/src/metabase/driver/generic_sql.clj +++ b/src/metabase/driver/generic_sql.clj @@ -11,7 +11,8 @@ (defrecord SqlDriver [column->base-type connection-details->connection-spec database->connection-details - sql-string-length-fn] + sql-string-length-fn + timezone->set-timezone-sql] IDriver ;; Connection (can-connect? [this database] diff --git a/src/metabase/driver/generic_sql/native.clj b/src/metabase/driver/generic_sql/native.clj index 6c141553f4d1f36a2eb19c81d635f617f77863d2..6e6f1045bda3191e5dffdb9dbeb93d36d8dbd664 100644 --- a/src/metabase/driver/generic_sql/native.clj +++ b/src/metabase/driver/generic_sql/native.clj @@ -10,18 +10,6 @@ [metabase.driver.generic-sql.util :refer :all] [metabase.models.database :refer [Database]])) -(def ^:dynamic *timezone->set-timezone-sql* - " This function is called whenever `timezone` is specified in a native query, at the beginning of - the DB transaction. - - If implemented, it should take a timestamp like `\"US/Pacific\"` and return a SQL - string that can be executed to set the timezone within the context of a transaction, - e.g. `\"SET LOCAL timezone to 'US/Pacific'\"`. - - Because not all DB engines support timestamps (e.g., H2), the default implementation is a no-op. - Engines that *do* support timestamps (e.g., Postgres) should override this function." - (fn [_])) - (defn- value->base-type "Attempt to match a value we get back from the DB with the corresponding base-type`." [v] @@ -48,9 +36,9 @@ ;; If timezone is specified in the Query and the driver supports setting the timezone then execute SQL to set it (when-let [timezone (or (-> query :native :timezone) (-> @(:organization database) :report_timezone))] - (when-let [set-timezone-sql (*timezone->set-timezone-sql* timezone)] + (when-let [timezone->set-timezone-sql (:timezone->set-timezone-sql (driver/database-id->driver database-id))] (log/debug "Setting timezone to:" timezone) - (jdbc/db-do-prepared conn set-timezone-sql))) + (jdbc/db-do-prepared conn (timezone->set-timezone-sql timezone)))) (jdbc/query conn sql :as-arrays? true))] {:rows rows :columns columns