mirror of
https://github.com/penpot/penpot.git
synced 2026-08-08 13:58:35 +00:00
🐛 Fix graph COPY ingest for multiline text names
This commit is contained in:
parent
76a0d9ef5e
commit
0443a8a28f
@ -24,9 +24,17 @@
|
||||
string fields are treated as column separators."
|
||||
"HEADER=true, DELIM=',', QUOTE='\"'")
|
||||
|
||||
(defn- csv-normalize-string
|
||||
"Graph node names are single-line labels; flatten Penpot text newlines."
|
||||
[s]
|
||||
(-> (str s)
|
||||
(str/replace #"\r\n" " ")
|
||||
(str/replace #"\r" " ")
|
||||
(str/replace #"\n" " ")))
|
||||
|
||||
(defn- csv-escape-string
|
||||
[s]
|
||||
(str "\"" (str/replace (str s) "\"" "\"\"") "\""))
|
||||
(str "\"" (str/replace (csv-normalize-string s) "\"" "\"\"") "\""))
|
||||
|
||||
(defn- csv-cell
|
||||
[v]
|
||||
|
||||
@ -92,7 +92,9 @@
|
||||
:statement statement
|
||||
:err err))))
|
||||
|
||||
(def ^:private default-query-timeout-seconds 120)
|
||||
(def ^:private default-query-timeout-ms
|
||||
"0 disables query timeout (recommended for bulk COPY ingest)."
|
||||
0)
|
||||
|
||||
(defn- scalar-value
|
||||
[^Connection conn statement]
|
||||
@ -119,9 +121,13 @@
|
||||
(defn with-connection!
|
||||
"Open a Ladybug connection for `db-path` and invoke `(f conn)`.
|
||||
|
||||
Options:
|
||||
- `:query-timeout-ms` query timeout in milliseconds (default 0, disabled)
|
||||
|
||||
For `:memory:`, the database only lives for the duration of this call;
|
||||
all reads and writes must happen inside `f`."
|
||||
[db-path f]
|
||||
[db-path f & {:keys [query-timeout-ms]
|
||||
:or {query-timeout-ms default-query-timeout-ms}}]
|
||||
(ensure-db-path! db-path)
|
||||
(let [^Database db (if (memory-db-path? db-path)
|
||||
(Database.)
|
||||
@ -129,7 +135,7 @@
|
||||
(try
|
||||
(let [^Connection conn (Connection. db)]
|
||||
(try
|
||||
(.setQueryTimeout conn default-query-timeout-seconds)
|
||||
(.setQueryTimeout conn (long query-timeout-ms))
|
||||
(f conn)
|
||||
(finally
|
||||
(.close conn))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user