Skip to content

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

fix(studio): serialize SQL folder deletion IDs (#50223)

Charis0bebe50a76e2
diff --git a/apps/studio/data/content/sql-folders-delete-mutation.test.ts b/apps/studio/data/content/sql-folders-delete-mutation.test.ts
new file mode 100644
index 00000000000..7d7774d802a
--- /dev/null
+++ b/apps/studio/data/content/sql-folders-delete-mutation.test.ts
@@ -0,0 +1,27 @@
+import { HttpResponse } from 'msw'
+import { describe, expect, it } from 'vitest'
+
+import { deleteSQLSnippetFolders } from './sql-folders-delete-mutation'
+import { addAPIMock } from '@/tests/lib/msw'
+
+describe('deleteSQLSnippetFolders', () => {
+ it('sends folder IDs as the comma-delimited query value required by the API', async () => {
+ let ids: string | null = null
+
+ addAPIMock({
+ method: 'delete',
+ path: '/platform/projects/:ref/content/folders',
+ response: ({ request }) => {
+ ids = new URL(request.url).searchParams.get('ids')
+ return HttpResponse.json({})
+ },
+ })
+
+ await deleteSQLSnippetFolders({
+ projectRef: 'default',
+ ids: ['folder-one', 'folder-two'],
+ })
+
+ expect(ids).toBe('folder-one,folder-two')
+ })
+})
diff --git a/apps/studio/data/content/sql-folders-delete-mutation.ts b/apps/studio/data/content/sql-folders-delete-mutation.ts
index 9cf2321aaf8..8a7fb0a00da 100644
--- a/apps/studio/data/content/sql-folders-delete-mutation.ts
+++ b/apps/studio/data/content/sql-folders-delete-mutation.ts
@@ -15,8 +15,8 @@ export async function deleteSQLSnippetFolders(
signal?: AbortSignal
) {
const { data, error } = await del('/platform/projects/{ref}/content/folders', {
- // @ts-ignore [Joshen] API codegen issue
- params: { path: { ref: projectRef }, query: { ids } },
+ // @ts-expect-error The generated endpoint type omits its required `{ref}` path parameter.
+ params: { path: { ref: projectRef }, query: { ids: ids.join(',') } },
signal,
})