diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.ts b/superset-frontend/src/SqlLab/actions/sqlLab.test.ts index ace26784469..ae53c83b77a 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.test.ts +++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.ts @@ -1420,39 +1420,6 @@ describe('async actions', () => { }); }); - // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks - describe('syncTable', () => { - test('updates the table schema state in the backend', () => { - expect.assertions(4); - - const tableName = 'table'; - const schemaName = 'schema'; - const store = mockStore(initialState); - const expectedActionTypes = [ - actions.MERGE_TABLE, // syncTable - ]; - const request = actions.syncTable( - query as any, - tableName as any, - schemaName, - ); - return request(store.dispatch, store.getState, undefined).then(() => { - expect(store.getActions().map(a => a.type)).toEqual( - expectedActionTypes, - ); - expect(store.getActions()[0].prepend).toBeFalsy(); - expect( - fetchMock.callHistory.calls(updateTableSchemaEndpoint), - ).toHaveLength(1); - - // tab state is not updated, since no query was run - expect( - fetchMock.callHistory.calls(updateTabStateEndpoint), - ).toHaveLength(0); - }); - }); - }); - // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks describe('runTablePreviewQuery', () => { const results = { diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.ts b/superset-frontend/src/SqlLab/actions/sqlLab.ts index 7058471a55b..072bfd05260 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.ts +++ b/superset-frontend/src/SqlLab/actions/sqlLab.ts @@ -1346,52 +1346,6 @@ export function runTablePreviewQuery( }; } -export interface TableMetaData { - columns?: unknown[]; - selectStar?: string; - primaryKey?: unknown; - foreignKeys?: unknown[]; - indexes?: unknown[]; -} - -export function syncTable( - table: Table, - tableMetadata: TableMetaData, - finalQueryEditorId?: string, -): SqlLabThunkAction> { - return function (dispatch: AppDispatch) { - const finalTable = { ...table, queryEditorId: finalQueryEditorId }; - const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) - ? SupersetClient.post({ - endpoint: encodeURI('/tableschemaview/'), - postPayload: { table: { ...tableMetadata, ...finalTable } }, - }) - : Promise.resolve({ json: { id: table.id } }); - - return sync - .then(({ json: resultJson }) => { - const newTable = { ...table, id: `${resultJson.id}` }; - dispatch( - mergeTable({ - ...newTable, - expanded: true, - initialized: true, - }), - ); - }) - .catch(() => - dispatch( - addDangerToast( - t( - 'An error occurred while fetching table metadata. ' + - 'Please contact your administrator.', - ), - ), - ), - ); - }; -} - export function changeDataPreviewId( oldQueryId: string, newQuery: Query,