豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit e48dae7

Browse files
justinparkmichael-s-molina
authored andcommitted
fix(sqllab): unable to remove table (#27636)
(cherry picked from commit fa3fea9)
1 parent 64d1a8f commit e48dae7

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

superset-frontend/src/SqlLab/actions/sqlLab.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,9 +1125,11 @@ export function removeTables(tables) {
11251125
const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)
11261126
? Promise.all(
11271127
tablesToRemove.map(table =>
1128-
SupersetClient.delete({
1129-
endpoint: encodeURI(`/tableschemaview/${table.id}`),
1130-
}),
1128+
table.initialized
1129+
? SupersetClient.delete({
1130+
endpoint: encodeURI(`/tableschemaview/${table.id}`),
1131+
})
1132+
: Promise.resolve(),
11311133
),
11321134
)
11331135
: Promise.resolve();

superset-frontend/src/SqlLab/actions/sqlLab.test.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ describe('async actions', () => {
883883
it('updates the table schema state in the backend', () => {
884884
expect.assertions(2);
885885

886-
const table = { id: 1 };
886+
const table = { id: 1, initialized: true };
887887
const store = mockStore({});
888888
const expectedActions = [
889889
{
@@ -900,7 +900,10 @@ describe('async actions', () => {
900900
it('deletes multiple tables and updates the table schema state in the backend', () => {
901901
expect.assertions(2);
902902

903-
const tables = [{ id: 1 }, { id: 2 }];
903+
const tables = [
904+
{ id: 1, initialized: true },
905+
{ id: 2, initialized: true },
906+
];
904907
const store = mockStore({});
905908
const expectedActions = [
906909
{
@@ -913,6 +916,23 @@ describe('async actions', () => {
913916
expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(2);
914917
});
915918
});
919+
920+
it('only updates the initialized table schema state in the backend', () => {
921+
expect.assertions(2);
922+
923+
const tables = [{ id: 1 }, { id: 2, initialized: true }];
924+
const store = mockStore({});
925+
const expectedActions = [
926+
{
927+
type: actions.REMOVE_TABLES,
928+
tables,
929+
},
930+
];
931+
return store.dispatch(actions.removeTables(tables)).then(() => {
932+
expect(store.getActions()).toEqual(expectedActions);
933+
expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1);
934+
});
935+
});
916936
});
917937

918938
describe('migrateQueryEditorFromLocalStorage', () => {

0 commit comments

Comments
 (0)