From e42622057bdd4d2b6d12dcf795de8e438a8ec3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cam=20Sa=C3=BCl?= <cammsaul@gmail.com> Date: Fri, 1 Jul 2016 12:25:37 -0700 Subject: [PATCH] Fix for Redshift :honey_pot: --- src/metabase/util/honeysql_extensions.clj | 2 +- test/metabase/test/data/generic_sql.clj | 21 +++++++++++---------- test/metabase/test/data/redshift.clj | 3 +-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/metabase/util/honeysql_extensions.clj b/src/metabase/util/honeysql_extensions.clj index e5ff948d8f6..c497ca1b7ad 100644 --- a/src/metabase/util/honeysql_extensions.clj +++ b/src/metabase/util/honeysql_extensions.clj @@ -32,7 +32,7 @@ ;; TODO - Maybe instead of this lozengey hackiness it would make more sense just to add a new "identifier" record type that implements `ToSql` in a more intelligent way (defn escape-dots "Replace dots in a string with WHITE MEDIUM LOZENGES (⬨)." - ^clojure.lang.Keyword [s] + ^String [s] (s/replace (name s) #"\." "⬨")) (defn qualify-and-escape-dots diff --git a/test/metabase/test/data/generic_sql.clj b/test/metabase/test/data/generic_sql.clj index 9d844f5415d..6c92c75be15 100644 --- a/test/metabase/test/data/generic_sql.clj +++ b/test/metabase/test/data/generic_sql.clj @@ -205,7 +205,7 @@ (defn- do-insert! "Insert ROWS-OR-ROWS into TABLE-NAME for the DRIVER database defined by SPEC." [driver spec table-name row-or-rows] - (let [prepare-key (comp keyword (partial prepare-identifier driver) hx/escape-dots name) + (let [prepare-key (comp keyword (partial prepare-identifier driver) name) rows (if (sequential? row-or-rows) row-or-rows [row-or-rows]) @@ -230,17 +230,18 @@ "Create a `load-data!` function. This creates a function to actually insert a row or rows, wraps it with any WRAP-INSERT-FNS, the calls the resulting function with the rows to insert." [& wrap-insert-fns] - (fn [driver dbdef tabledef] - (let [spec (database->spec driver :db dbdef) - insert! ((apply comp wrap-insert-fns) (partial do-insert! driver spec (:table-name tabledef))) - rows (load-data-get-rows driver dbdef tabledef)] + (fn [driver {:keys [database-name], :as dbdef} {:keys [table-name], :as tabledef}] + (let [spec (database->spec driver :db dbdef) + table-name (apply hx/qualify-and-escape-dots (qualified-name-components driver database-name table-name)) + insert! ((apply comp wrap-insert-fns) (partial do-insert! driver spec table-name)) + rows (load-data-get-rows driver dbdef tabledef)] (insert! rows)))) -(def load-data-all-at-once! "Insert all rows at once." (make-load-data-fn)) -(def load-data-chunked! "Insert rows in chunks of 200 at a time." (make-load-data-fn load-data-chunked)) -(def load-data-one-at-a-time! "Insert rows one at a time." (make-load-data-fn load-data-one-at-a-time)) -(def load-data-chunked-parallel! "Insert rows in chunks of 200 at a time, in parallel." (make-load-data-fn load-data-add-ids (partial load-data-chunked pmap))) -(def load-data-one-at-a-time-parallel! "Insert rows one at a time, in parallel." (make-load-data-fn load-data-add-ids (partial load-data-one-at-a-time pmap))) +(def load-data-all-at-once! "Insert all rows at once." (make-load-data-fn)) +(def load-data-chunked! "Insert rows in chunks of 200 at a time." (make-load-data-fn load-data-chunked)) +(def load-data-one-at-a-time! "Insert rows one at a time." (make-load-data-fn load-data-one-at-a-time)) +(def load-data-chunked-parallel! "Insert rows in chunks of 200 at a time, in parallel." (make-load-data-fn load-data-add-ids (partial load-data-chunked pmap))) +(def load-data-one-at-a-time-parallel! "Insert rows one at a time, in parallel." (make-load-data-fn load-data-add-ids (partial load-data-one-at-a-time pmap))) (defn default-execute-sql! [driver context dbdef sql] diff --git a/test/metabase/test/data/redshift.clj b/test/metabase/test/data/redshift.clj index a668c235d82..b8c44918527 100644 --- a/test/metabase/test/data/redshift.clj +++ b/test/metabase/test/data/redshift.clj @@ -64,8 +64,7 @@ {:create-db-sql (constantly nil) :drop-db-if-exists-sql (constantly nil) :drop-table-if-exists-sql generic/drop-table-if-exists-cascade-sql - :field-base-type->sql-type (fn [_ base-type] - (field-base-type->sql-type base-type)) + :field-base-type->sql-type (u/drop-first-arg field-base-type->sql-type) :pk-sql-type (constantly "INTEGER IDENTITY(1,1)") :qualified-name-components qualified-name-components}) -- GitLab