The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: fix quoting for json column export (#34799)
Etienne Stalmans9fc77a7d5114
diff --git a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.test.ts b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.test.tsindex ce126495d54..9a52aa4795a 100644--- a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.test.ts+++ b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.test.ts@@ -70,9 +70,16 @@ describe('TableEntity.utils: formatTableRowsToSQL', () => {tags: ['tag-a', 'tag-c'],metadata: '{"version": 1}',},+ {+ idx: 2,+ id: 3,+ name: 'ONeil',+ tags: ['tag-a'],+ metadata: `{"version": 1, "name": "O'Neil"}`,+ },]const result = formatTableRowsToSQL(table, rows)- const expected = `INSERT INTO "public"."demo" ("id", "name", "tags", "metadata") VALUES ('2', 'Person 1', '{"tag-a","tag-c"}', '{"version": 1}');`+ const expected = `INSERT INTO "public"."demo" ("id", "name", "tags", "metadata") VALUES ('2', 'Person 1', '{"tag-a","tag-c"}', '{"version": 1}'), ('3', 'ONeil', '{"tag-a"}', '{"version": 1, "name": "O''Neil"}');`expect(result).toBe(expected)})diff --git a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.tsindex e464c8a17bc..41afdff8602 100644--- a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts+++ b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts@@ -44,7 +44,7 @@ export const formatTableRowsToSQL = (table: SupaTable, rows: any[]) => {} else if (dataType === 'ARRAY') {return `'${JSON.stringify(val).replace('[', '{').replace(/.$/, '}')}'`} else if (format?.includes('json')) {- return `${JSON.stringify(val).replace(/\\"/g, '"').replace('"', "'").replace(/.$/, "'")}`+ return `${JSON.stringify(val).replace(/\\"/g, '"').replace(/'/g, "''").replace('"', "'").replace(/.$/, "'")}`} else {return `'${val}'`}