mirror of
https://github.com/apache/superset.git
synced 2024-09-17 19:19:38 -04:00
fix(sqllab): unable to remove table (#27636)
(cherry picked from commit fa3fea9dd8
)
This commit is contained in:
parent
29553939a2
commit
32aa25ae17
@ -1130,9 +1130,11 @@ export function removeTables(tables) {
|
||||
const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
|
||||
? Promise.all(
|
||||
tablesToRemove.map(table =>
|
||||
SupersetClient.delete({
|
||||
table.initialized
|
||||
? SupersetClient.delete({
|
||||
endpoint: encodeURI(`/tableschemaview/${table.id}`),
|
||||
}),
|
||||
})
|
||||
: Promise.resolve(),
|
||||
),
|
||||
)
|
||||
: Promise.resolve();
|
||||
|
@ -883,7 +883,7 @@ describe('async actions', () => {
|
||||
it('updates the table schema state in the backend', () => {
|
||||
expect.assertions(2);
|
||||
|
||||
const table = { id: 1 };
|
||||
const table = { id: 1, initialized: true };
|
||||
const store = mockStore({});
|
||||
const expectedActions = [
|
||||
{
|
||||
@ -900,7 +900,10 @@ describe('async actions', () => {
|
||||
it('deletes multiple tables and updates the table schema state in the backend', () => {
|
||||
expect.assertions(2);
|
||||
|
||||
const tables = [{ id: 1 }, { id: 2 }];
|
||||
const tables = [
|
||||
{ id: 1, initialized: true },
|
||||
{ id: 2, initialized: true },
|
||||
];
|
||||
const store = mockStore({});
|
||||
const expectedActions = [
|
||||
{
|
||||
@ -913,6 +916,23 @@ describe('async actions', () => {
|
||||
expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('only updates the initialized table schema state in the backend', () => {
|
||||
expect.assertions(2);
|
||||
|
||||
const tables = [{ id: 1 }, { id: 2, initialized: true }];
|
||||
const store = mockStore({});
|
||||
const expectedActions = [
|
||||
{
|
||||
type: actions.REMOVE_TABLES,
|
||||
tables,
|
||||
},
|
||||
];
|
||||
return store.dispatch(actions.removeTables(tables)).then(() => {
|
||||
expect(store.getActions()).toEqual(expectedActions);
|
||||
expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('migrateQueryEditorFromLocalStorage', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user