From 25af9fa6d3521e6b1c102f42c29b6a9080fb6bd5 Mon Sep 17 00:00:00 2001 From: hallidayo <22655069+Hallidayo@users.noreply.github.com> Date: Wed, 3 Sep 2025 21:59:18 +0100 Subject: [PATCH 1/2] fix: add apostrophe for sql export (#37920) * add apostrophe for sql export * refactor: move quote escape logic to common util --------- Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com> --- .../interfaces/TableGridEditor/TableEntity.utils.ts | 9 +++++++++ .../layouts/TableEditorLayout/EntityListItem.tsx | 10 ++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts index 41afdff860200..7d208f3b351e5 100644 --- a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts +++ b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts @@ -39,12 +39,21 @@ export const formatTableRowsToSQL = (table: SupaTable, rows: any[]) => { // We only check for NULL, array and JSON types, everything else we stringify // given that Postgres can implicitly cast the right type based on the column type + // For string types, we need to deal with escaping single quotes + const stringFormats = ['text', 'varchar'] + if (val === null) { return 'null' } else if (dataType === 'ARRAY') { return `'${JSON.stringify(val).replace('[', '{').replace(/.$/, '}')}'` } else if (format?.includes('json')) { return `${JSON.stringify(val).replace(/\\"/g, '"').replace(/'/g, "''").replace('"', "'").replace(/.$/, "'")}` + } else if ( + typeof format === 'string' && + typeof val === 'string' && + stringFormats.includes(format) + ) { + return `'${val.replaceAll("'", "''")}'` } else { return `'${val}'` } diff --git a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx index f835be98f68b7..84dff45cae3d2 100644 --- a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx +++ b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx @@ -210,11 +210,13 @@ const EntityListItem: ItemRenderer = ({ connectionString: project?.connectionString, table: supaTable, }) + const formattedRows = rows.map((row) => { - const formattedRow = row - Object.keys(row).map((column) => { - if (typeof row[column] === 'object' && row[column] !== null) - formattedRow[column] = JSON.stringify(formattedRow[column]) + const formattedRow = { ...row } + Object.keys(row).forEach((column) => { + if (typeof row[column] === 'object' && row[column] !== null) { + formattedRow[column] = JSON.stringify(row[column]) + } }) return formattedRow }) From 0baa7e53c6f2b2aff95017a748fbd92439a633e8 Mon Sep 17 00:00:00 2001 From: Charis <26616127+charislam@users.noreply.github.com> Date: Wed, 3 Sep 2025 17:19:22 -0400 Subject: [PATCH 2/2] chore: fix misspelling triggering the misspell checker (#38419) --- .../interfaces/Storage/__tests__/EmptyBucketModal.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/studio/components/interfaces/Storage/__tests__/EmptyBucketModal.test.tsx b/apps/studio/components/interfaces/Storage/__tests__/EmptyBucketModal.test.tsx index a9b79f4daa36b..dd76310edc547 100644 --- a/apps/studio/components/interfaces/Storage/__tests__/EmptyBucketModal.test.tsx +++ b/apps/studio/components/interfaces/Storage/__tests__/EmptyBucketModal.test.tsx @@ -69,7 +69,7 @@ describe(`EmptyBucketModal`, () => { path: `/platform/storage/:ref/buckets/:id/empty`, }) // Called by useStorageExplorerStateSnapshot but seems - // to be unnecessary for succesful test? + // to be unnecessary for successful test? // // useProjectSettingsV2Query -> ProjectSettings // GET /platform/projects/:ref/settings