Skip to content
Snippets Groups Projects
Commit e4262205 authored by Cam Saül's avatar Cam Saül
Browse files

Fix for Redshift :honey_pot:

parent 1e93aa5c
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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]
......
......@@ -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})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment