Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(logs): load saved query content from api instead of stale url param FE-3733 (#47393)

Jordi Enric6ba5bef9dae2
diff --git a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
index a34095698ed..1fb54164151 100644
--- a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
+++ b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
@@ -408,17 +408,21 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
}))
}
+ const querySql = (query?.content as LogSqlSnippets.Content | undefined)?.sql
useEffect(() => {
if (search) {
setEditorValue(search)
- } else if (q) {
+ } else if (q && !queryId) {
setEditorValue(q)
setSearch(q)
+ } else if (queryId && querySql) {
+ setEditorValue(querySql)
+ editorRef.current?.setValue(querySql)
} else if (!queryId) {
setEditorValue(PLACEHOLDER_QUERY)
editorRef.current?.setValue(PLACEHOLDER_QUERY)
}
- }, [q, search, queryId, setSearch, PLACEHOLDER_QUERY])
+ }, [q, search, queryId, querySql, setSearch, PLACEHOLDER_QUERY])
useEffect(() => {
// prevents overwriting when the user selects a helper.