From 092d30d4385b0aa9beca9b9f367308902b92e377 Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Mon, 16 Dec 2024 17:37:32 +0100 Subject: [PATCH] Fetch the snippet content if it's empty. --- apps/studio/pages/project/[ref]/sql/[id].tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/studio/pages/project/[ref]/sql/[id].tsx b/apps/studio/pages/project/[ref]/sql/[id].tsx index 17a669872d6..ecf62988ca7 100644 --- a/apps/studio/pages/project/[ref]/sql/[id].tsx +++ b/apps/studio/pages/project/[ref]/sql/[id].tsx @@ -39,7 +39,9 @@ const SqlEditor: NextPageWithLayout = () => { // Don't fetch the snippet if it already exists in the state. This avoids a race condition where // the snippet is inserted and fetched at the same time. - const existsSnippet = id ? !!snapV2.snippets[id] : undefined + const existsSnippet = id + ? id in snapV2.snippets && snapV2.snippets[id].snippet?.content !== undefined + : undefined useContentIdQuery( { projectRef: ref, id },