From efadca5e785a4cd69454778a5ffcdd41b248a537 Mon Sep 17 00:00:00 2001 From: Guillaume Hivert Date: Sat, 6 Jul 2024 23:15:33 +0200 Subject: [PATCH] fix: correctly compute indexes --- apps/backend/src/backend/gleam/parse.gleam | 4 ++-- apps/backend/src/backend/postgres/queries.gleam | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/backend/src/backend/gleam/parse.gleam b/apps/backend/src/backend/gleam/parse.gleam index 7b4ca10..03f985d 100644 --- a/apps/backend/src/backend/gleam/parse.gleam +++ b/apps/backend/src/backend/gleam/parse.gleam @@ -130,8 +130,8 @@ fn replace_indexed( case kind { Index(name, _) -> { case dict.get(indexes, name) { - Ok(value) -> #(Index(name, value), #(indexes, current)) - Error(_) -> #(Index(name, current), #( + Ok(value) -> #(Index("", value), #(indexes, current)) + Error(_) -> #(Index("", current), #( dict.insert(indexes, name, current), current + 1, )) diff --git a/apps/backend/src/backend/postgres/queries.gleam b/apps/backend/src/backend/postgres/queries.gleam index e22485c..ff3ce7b 100644 --- a/apps/backend/src/backend/postgres/queries.gleam +++ b/apps/backend/src/backend/postgres/queries.gleam @@ -607,6 +607,7 @@ pub fn module_search(db: pgo.Connection, q: String) { } pub fn exact_type_search(db: pgo.Connection, q: List(Int)) { + use <- bool.guard(when: list.is_empty(q), return: Ok([])) let ids = list.index_map(q, fn(_, idx) { "$" <> int.to_string(idx + 1) }) |> string.join(", ")