Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqllab): unable to remove table #27636

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,11 @@ export function removeTables(tables) {
const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
? Promise.all(
tablesToRemove.map(table =>
SupersetClient.delete({
endpoint: encodeURI(`/tableschemaview/${table.id}`),
}),
table.initialized
? SupersetClient.delete({
endpoint: encodeURI(`/tableschemaview/${table.id}`),
})
: Promise.resolve(),
),
)
: Promise.resolve();
Expand Down
24 changes: 22 additions & 2 deletions superset-frontend/src/SqlLab/actions/sqlLab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand All @@ -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 = [
{
Expand All @@ -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', () => {
Expand Down
Loading