Skip to content

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

Small fix

Joshen Limd7cd32d07087
diff --git a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx b/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
index 7571d5f2c9b..37393cd18c8 100644
--- a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
+++ b/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
@@ -85,7 +85,7 @@ const QueryItemActions = observer(({ tabInfo }: { tabInfo: SqlSnippet }) => {
try {
await deleteContent({ projectRef: ref, id })
- const existingSnippetIds = Object.keys(snap.snippets).filter((x) => x !== id)
+ const existingSnippetIds = (snap.orders[ref] ?? []).filter((x) => x !== id)
if (existingSnippetIds.length === 0) {
router.push(`/project/${ref}/sql`)
} else {
diff --git a/studio/state/sql-editor.ts b/studio/state/sql-editor.ts
index 4ce5d62fed8..ef64a8f620d 100644
--- a/studio/state/sql-editor.ts
+++ b/studio/state/sql-editor.ts
@@ -23,6 +23,7 @@ export const sqlEditorState = proxy({
error?: any
}[]
},
+ // Project ref as the key, ids of each snippet as the order
orders: {} as {
[key: string]: string[]
},