Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Commit a3713f9

Browse files
committed
Handle quoting style of MySQL
1 parent 08a813c commit a3713f9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject googlesheets-sql-sync "0.5.0"
1+
(defproject googlesheets-sql-sync "0.5.1"
22
:description "Keep your SQL database in sync with Google Sheets"
33
:url "https://github.com/jorinvo/googlesheets-sql-sync"
44
:license {:name "MIT"

src/googlesheets_sql_sync/db.clj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
[googlesheets-sql-sync.log :as log]
66
[googlesheets-sql-sync.util :refer [fail]]))
77

8+
(def identifier-quoting-map
9+
{:postgresql "\""
10+
:mysql "`"})
11+
812
(defn- escape
913
"Replace all c in text with \\c"
1014
[text c]
@@ -87,12 +91,13 @@
8791
(defn update-table [config sheet]
8892
(let [target (-> sheet :sheet :target)
8993
db (get-in config [:targets (keyword target)])
94+
identifier-quoting (:dbtype identifier-quoting-map)
9095
table (-> sheet :sheet :table)
9196
rows (:rows sheet)
9297
headers (->> rows
9398
first
94-
(map #(escape % "\"")))
95-
escaped-headers (map #(str "\"" % "\"") headers)
99+
(map #(escape % identifier-quoting)))
100+
escaped-headers (map #(str identifier-quoting % identifier-quoting) headers)
96101
header-count (count headers)
97102
data (->> (rest rows)
98103
(map #(map string/trim %))

0 commit comments

Comments
 (0)