🐛 Fix graph COPY ingest for multiline text names

This commit is contained in:
Alejandro Alonso 2026-07-14 08:27:08 +02:00 committed by Álvaro Tejero Cantero
parent aeb3b7967a
commit ff60ce70bf
No known key found for this signature in database
2 changed files with 18 additions and 4 deletions

View File

@ -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]

View File

@ -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))))