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

Commit fa3fea9

Browse files
authored
fix(sqllab): unable to remove table (#27636)
1 parent ce210ee commit fa3fea9

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
@@ -1131,9 +1131,11 @@ export function removeTables(tables) {
11311131
const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
11321132
? Promise.all(
11331133
tablesToRemove.map(table =>
1134-
SupersetClient.delete({
1135-
endpoint: encodeURI(`/tableschemaview/${table.id}`),
1136-
}),
1134+
table.initialized
1135+
? SupersetClient.delete({
1136+
endpoint: encodeURI(`/tableschemaview/${table.id}`),
1137+
})
1138+
: Promise.resolve(),
11371139
),
11381140
)
11391141
: 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)