From 35ee01040792bcf63f676983e655f1289451748c Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 27 Jan 2023 13:45:53 +0800 Subject: [PATCH] chore: update null check --- studio/components/interfaces/Database/Tables/ColumnList.tsx | 4 ++-- .../SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx | 2 +- .../components/interfaces/TableGridEditor/TableGridEditor.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/studio/components/interfaces/Database/Tables/ColumnList.tsx b/studio/components/interfaces/Database/Tables/ColumnList.tsx index 7be131dee70..c5b668777fc 100644 --- a/studio/components/interfaces/Database/Tables/ColumnList.tsx +++ b/studio/components/interfaces/Database/Tables/ColumnList.tsx @@ -27,9 +27,9 @@ const ColumnList: FC = ({ const columns = (filterString.length === 0 ? selectedTable.columns - : selectedTable.columns!.filter((column: any) => column.name.includes(filterString))) ?? [] + : selectedTable.columns?.filter((column: any) => column.name.includes(filterString))) ?? [] - const isLocked = meta.excludedSchemas.includes(selectedTable?.schema ?? '') + const isLocked = meta.excludedSchemas.includes(selectedTable.schema ?? '') return ( <> diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx index 7acd632eaf6..e8146e33c43 100644 --- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx +++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx @@ -71,7 +71,7 @@ const ForeignKeySelector: FC = ({ setSelectedForeignKey({ schema: table.schema, table: table.name, - column: table.columns!.length > 0 ? table.columns![0].name : undefined, + column: table.columns?.length ? table.columns[0].name : undefined, }) } } diff --git a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx index 26e1b54f45c..e62bfe19e34 100644 --- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx +++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx @@ -92,7 +92,7 @@ const TableGridEditor: FC = ({ ? parseSupaTable( { table: selectedTable as PostgresTable, - columns: (selectedTable as PostgresTable).columns!, + columns: (selectedTable as PostgresTable).columns ?? [], primaryKeys: (selectedTable as PostgresTable).primary_keys, relationships: (selectedTable as PostgresTable).relationships, },