mirror of
https://github.com/penpot/penpot.git
synced 2026-08-16 09:49:05 +00:00
🐛 Fix graph COPY ingest for multiline text names
This commit is contained in:
parent
aeb3b7967a
commit
ff60ce70bf
@ -24,9 +24,17 @@
|
|||||||
string fields are treated as column separators."
|
string fields are treated as column separators."
|
||||||
"HEADER=true, DELIM=',', QUOTE='\"'")
|
"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
|
(defn- csv-escape-string
|
||||||
[s]
|
[s]
|
||||||
(str "\"" (str/replace (str s) "\"" "\"\"") "\""))
|
(str "\"" (str/replace (csv-normalize-string s) "\"" "\"\"") "\""))
|
||||||
|
|
||||||
(defn- csv-cell
|
(defn- csv-cell
|
||||||
[v]
|
[v]
|
||||||
|
|||||||
@ -92,7 +92,9 @@
|
|||||||
:statement statement
|
:statement statement
|
||||||
:err err))))
|
: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
|
(defn- scalar-value
|
||||||
[^Connection conn statement]
|
[^Connection conn statement]
|
||||||
@ -119,9 +121,13 @@
|
|||||||
(defn with-connection!
|
(defn with-connection!
|
||||||
"Open a Ladybug connection for `db-path` and invoke `(f conn)`.
|
"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;
|
For `:memory:`, the database only lives for the duration of this call;
|
||||||
all reads and writes must happen inside `f`."
|
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)
|
(ensure-db-path! db-path)
|
||||||
(let [^Database db (if (memory-db-path? db-path)
|
(let [^Database db (if (memory-db-path? db-path)
|
||||||
(Database.)
|
(Database.)
|
||||||
@ -129,7 +135,7 @@
|
|||||||
(try
|
(try
|
||||||
(let [^Connection conn (Connection. db)]
|
(let [^Connection conn (Connection. db)]
|
||||||
(try
|
(try
|
||||||
(.setQueryTimeout conn default-query-timeout-seconds)
|
(.setQueryTimeout conn (long query-timeout-ms))
|
||||||
(f conn)
|
(f conn)
|
||||||
(finally
|
(finally
|
||||||
(.close conn))))
|
(.close conn))))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user