From 2aa2525d0efe7ca9cf24e7ca2123276801f1c7c0 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 29 Apr 2025 14:23:28 +0200 Subject: [PATCH] :sparkles: Add db conn dynamic binding for srepl helpers --- backend/src/app/db.clj | 2 ++ backend/src/app/srepl/main.clj | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/app/db.clj b/backend/src/app/db.clj index bbb5fed43..4a583256e 100644 --- a/backend/src/app/db.clj +++ b/backend/src/app/db.clj @@ -42,6 +42,8 @@ org.postgresql.util.PGInterval org.postgresql.util.PGobject)) +(def ^:dynamic *conn* nil) + (declare open) (declare create-pool) diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index 4b00767ee..da4b45eda 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -423,7 +423,8 @@ (let [file-id (h/parse-uuid file-id)] (db/tx-run! (assoc main/system ::db/rollback rollback?) (fn [system] - (binding [h/*system* system] + (binding [h/*system* system + db/*conn* (db/get-connection system)] (h/process-file! system file-id update-fn opts)))))) (defn process-team-files! @@ -436,7 +437,8 @@ (when (string? label) (h/take-team-snapshot! system team-id label)) - (binding [h/*system* system] + (binding [h/*system* system + db/*conn* (db/get-connection system)] (->> (feat.comp-v2/get-and-lock-team-files conn team-id) (reduce (fn [result file-id] (if (h/process-file! system file-id update-fn opts)