From 329e72885c20d3a36f70dbe2909c4665f51ec92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=88=E1=B5=83=E1=B5=A2?= Date: Tue, 10 Nov 2020 15:26:29 -1000 Subject: [PATCH] fix(saved-query): handle case where sql_tables in undefined (#11649) --- .../CRUD/data/savedquery/SavedQueryList.tsx | 16 ++++++++++------ superset-frontend/src/views/CRUD/types.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx b/superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx index bfb471937..88ed0154a 100644 --- a/superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx +++ b/superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx @@ -245,7 +245,7 @@ function SavedQueryList({ { Cell: ({ row: { - original: { sql_tables: tables }, + original: { sql_tables: tables = [] }, }, }: any) => { const names = tables.map((table: any) => table.table); @@ -385,9 +385,11 @@ function SavedQueryList({ 'saved_query', 'database', createErrorHandler(errMsg => - t( - 'An error occurred while fetching dataset datasource values: %s', - errMsg, + addDangerToast( + t( + 'An error occurred while fetching dataset datasource values: %s', + errMsg, + ), ), ), ), @@ -403,7 +405,9 @@ function SavedQueryList({ 'saved_query', 'schema', createErrorHandler(errMsg => - t('An error occurred while fetching schema values: %s', errMsg), + addDangerToast( + t('An error occurred while fetching schema values: %s', errMsg), + ), ), ), paginate: true, @@ -415,7 +419,7 @@ function SavedQueryList({ operator: 'all_text', }, ], - [], + [addDangerToast], ); return ( diff --git a/superset-frontend/src/views/CRUD/types.ts b/superset-frontend/src/views/CRUD/types.ts index 4ce59123f..27e5f000e 100644 --- a/superset-frontend/src/views/CRUD/types.ts +++ b/superset-frontend/src/views/CRUD/types.ts @@ -57,5 +57,5 @@ export type SavedQueryObject = { label: string; schema: string; sql: string; - sql_tables: Array<{ catalog?: string; schema: string; table: string }>; + sql_tables?: { catalog?: string; schema: string; table: string }[]; };