The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix can't edit column after creating error
Alaister Young76d84cda7047
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsxindex e4a495e8fb5..dc9aa678a3c 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx@@ -244,8 +244,9 @@ const SidePanelEditor = ({) {reAddRenamedColumnSortAndFilter(selectedColumnToEdit.name, payload.name)}- queryClient.invalidateQueries(sqlKeys.query(project?.ref, ['foreign-key-constraints']))+await Promise.all([+ queryClient.invalidateQueries(sqlKeys.query(project?.ref, ['foreign-key-constraints'])),queryClient.invalidateQueries(tableKeys.table(project?.ref, selectedTable!.id)),queryClient.invalidateQueries(sqlKeys.query(project?.ref, [selectedTable!.schema, selectedTable!.name])diff --git a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsxindex 5f62aaafe73..a0f15ceb6fd 100644--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx@@ -27,10 +27,11 @@ import { useProjectJsonSchemaQuery } from 'data/docs/project-json-schema-query'import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'import { sqlKeys } from 'data/sql/keys'import { useTableRowUpdateMutation } from 'data/table-rows/table-row-update-mutation'-import { useCheckPermissions, useStore, useUrlState } from 'hooks'+import { useCheckPermissions, useLatest, useStore, useUrlState } from 'hooks'import useEntityType from 'hooks/misc/useEntityType'import { TableLike } from 'hooks/misc/useTable'import { EXCLUDED_SCHEMAS } from 'lib/constants/schemas'+import { EMPTY_ARR } from 'lib/void'import { useTableEditorStateSnapshot } from 'state/table-editor'import { SchemaView } from 'types'import APIDocumentationPanel from './APIDocumentationPanel'@@ -157,12 +158,13 @@ const TableGridEditor = ({}, [selectedTable?.id])const entityType = useEntityType(selectedTable?.id)+ const columnsRef = useLatest(selectedTable?.columns ?? EMPTY_ARR)+ // NOTE: DO NOT PUT HOOKS AFTER THIS LINEif (isLoadingSelectedTable) {return <Connecting />}- // NOTE: DO NOT PUT HOOKS AFTER THIS LINEif (isUndefined(selectedTable)) {return <NotFoundState id={Number(id)} />}@@ -234,8 +236,11 @@ const TableGridEditor = ({}}- const onSelectEditColumn = async (name: string) => {- const column = find(selectedTable?.columns ?? [], { name }) as PostgresColumn+ // columns must be accessed via columnsRef.current as these two functions immediately become+ // stale as they are accessed via some react-tracked madness+ // [TODO]: refactor out all of react-tracked+ const onSelectEditColumn = (name: string) => {+ const column = find(columnsRef.current, { name }) as PostgresColumnif (column) {snap.onEditColumn(column)} else {@@ -246,8 +251,8 @@ const TableGridEditor = ({}}- const onSelectDeleteColumn = async (name: string) => {- const column = find(selectedTable?.columns ?? [], { name }) as PostgresColumn+ const onSelectDeleteColumn = (name: string) => {+ const column = find(columnsRef.current ?? [], { name }) as PostgresColumnif (column) {snap.onDeleteColumn(column)} else {