From 781975775918ac0880a9499460b7062e4bf9556e Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 4 Jun 2021 14:01:05 +0200 Subject: [PATCH] :bug: Fix unexpected exception on searching without term. When term is empty on frontend, frontend just does not sends it to backend, leving it as missing field. This commit makes the seatch-term as optional. --- backend/src/app/rpc/queries/files.clj | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/src/app/rpc/queries/files.clj b/backend/src/app/rpc/queries/files.clj index 3fa857892..dd36c6413 100644 --- a/backend/src/app/rpc/queries/files.clj +++ b/backend/src/app/rpc/queries/files.clj @@ -112,14 +112,16 @@ order by f.created_at asc") (s/def ::search-files - (s/keys :req-un [::profile-id ::team-id ::search-term])) + (s/keys :req-un [::profile-id ::team-id] + :opt-un [::search-term])) (sv/defmethod ::search-files [{:keys [pool] :as cfg} {:keys [profile-id team-id search-term] :as params}] - (db/exec! pool [sql:search-files - profile-id team-id - profile-id team-id - search-term])) + (when search-term + (db/exec! pool [sql:search-files + profile-id team-id + profile-id team-id + search-term]))) ;; --- Query: Files