From 0443a8a28f5701ff004e361d0a82bc8083510711 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 14 Jul 2026 08:27:08 +0200 Subject: [PATCH] :bug: Fix graph COPY ingest for multiline text names --- backend/src/app/graph/bulk.clj | 10 +++++++++- backend/src/app/graph/ladybug.clj | 12 +++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/backend/src/app/graph/bulk.clj b/backend/src/app/graph/bulk.clj index 2cb4518dff..1e057ccb3c 100644 --- a/backend/src/app/graph/bulk.clj +++ b/backend/src/app/graph/bulk.clj @@ -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] diff --git a/backend/src/app/graph/ladybug.clj b/backend/src/app/graph/ladybug.clj index af5f45f9a4..62648ff112 100644 --- a/backend/src/app/graph/ladybug.clj +++ b/backend/src/app/graph/ladybug.clj @@ -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))))