The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix table editor hiding errors when updating columns
Joshen Lim55579a1b0fe9
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsxindex 2efd9fe712d..85eed831540 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx@@ -195,12 +195,25 @@ const SidePanelEditor: FC<Props> = ({category: 'loading',message: `Updating table: ${selectedTableToEdit?.name}...`,})- const table: any = await meta.updateTable(toastId, selectedTableToEdit, payload, columns)- ui.setNotification({- id: toastId,- category: 'success',- message: `Successfully updated ${table.name}!`,- })+ const { table, hasError }: any = await meta.updateTable(+ toastId,+ selectedTableToEdit,+ payload,+ columns+ )+ if (hasError) {+ ui.setNotification({+ id: toastId,+ category: 'info',+ message: `Table ${table.name} has been updated, but there were some errors`,+ })+ } else {+ ui.setNotification({+ id: toastId,+ category: 'success',+ message: `Successfully updated ${table.name}!`,+ })+ }}} catch (error: any) {saveTableError = truediff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsxindex 9a32b3f4cc9..fcf02df4032 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx@@ -22,7 +22,6 @@ import {generateTableFieldFromPostgresTable,formatImportedContentToColumnFields,} from './TableEditor.utils'-import SidePanelEditor from '..'interface Props {table?: PostgresTablediff --git a/studio/stores/pgmeta/MetaStore.ts b/studio/stores/pgmeta/MetaStore.tsindex c2954314903..c625ac9339b 100644--- a/studio/stores/pgmeta/MetaStore.ts+++ b/studio/stores/pgmeta/MetaStore.ts@@ -516,6 +516,7 @@ export default class MetaStore implements IMetaStore {}// Add any new columns / Update any existing columns+ let hasError = falsefor (const column of columns) {if (!column.id.includes(table.id.toString())) {this.rootStore.ui.setNotification({@@ -546,7 +547,19 @@ export default class MetaStore implements IMetaStore {category: 'loading',message: `Updating column ${column.name} from ${updatedTable.name}`,})- await this.updateColumn(column.id, columnPayload, updatedTable, column.foreignKey)+ const res: any = await this.updateColumn(+ column.id,+ columnPayload,+ updatedTable,+ column.foreignKey+ )+ if (res?.error) {+ hasError = true+ this.rootStore.ui.setNotification({+ category: 'error',+ message: `Failed to update column "${column.name}": ${res.error.message}`,+ })+ }}}}@@ -562,7 +575,7 @@ export default class MetaStore implements IMetaStore {if (primaryKeys.error) throw primaryKeys.error}- return await this.tables.loadById(table.id)+ return { table: await this.tables.loadById(table.id), hasError }}async insertRowsViaSpreadsheet(