From e12c08b0eacddefd4593f1d788fa57f8d7cdf7c8 Mon Sep 17 00:00:00 2001 From: Mehmet Salih Yavuz Date: Tue, 7 Jul 2026 10:19:25 +0300 Subject: [PATCH] fix(sqllab): preserve saved query description when editing (#41685) (cherry picked from commit de5a233ccf9f3a0e69e1e0beebea148263753a86) --- .../src/SqlLab/actions/sqlLab.js | 1 + .../src/SqlLab/actions/sqlLab.test.js | 3 +- .../components/SaveQuery/SaveQuery.test.tsx | 41 +++++++++++++++++++ .../src/SqlLab/components/SaveQuery/index.tsx | 12 ++++-- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 3b48c536f7b..c9a7982c9b4 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1245,6 +1245,7 @@ export function popSavedQuery(saveQueryId) { }; const tmpAdaptedProps = { name: queryEditorProps.name, + description: queryEditorProps.description, dbId: queryEditorProps.database.id, catalog: queryEditorProps.catalog, schema: queryEditorProps.schema, diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.js b/superset-frontend/src/SqlLab/actions/sqlLab.test.js index a3327023c70..412116c17c1 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.test.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.js @@ -670,7 +670,7 @@ describe('async actions', () => { database_name: 'examples', id: 2, }, - description: '', + description: 'A saved query description', id: 1, label: 'Query 1', schema: 'public', @@ -720,6 +720,7 @@ describe('async actions', () => { const expectedParams = { name: 'Query 1', + description: 'A saved query description', dbId: 2, catalog: null, schema: 'public', diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx index f375b4cb4ad..56dea15f4d1 100644 --- a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx +++ b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx @@ -171,6 +171,47 @@ describe('SavedQuery', () => { expect(updateBtn).toBeInTheDocument(); }); + test('pre-fills the description from an existing saved query and updates with it unchanged', async () => { + const storedDescription = 'This is the stored description'; + const mockOnUpdate = jest.fn(); + + render(, { + useRedux: true, + store: mockStore({ + ...mockState, + sqlLab: { + ...mockState.sqlLab, + queryEditors: [ + { + id: mockedProps.queryEditorId, + dbId: 1, + catalog: null, + schema: 'main', + sql: 'SELECT * FROM t', + name: 'My saved query', + description: storedDescription, + remoteId: 42, + }, + ], + }, + }), + }); + + userEvent.click(screen.getByRole('button', { name: /save/i })); + + const descriptionTextbox = screen.getByRole('textbox', { + name: 'Description', + }); + expect(descriptionTextbox).toHaveValue(storedDescription); + + userEvent.click(screen.getByRole('button', { name: /update/i })); + + await waitFor(() => expect(mockOnUpdate).toHaveBeenCalled()); + expect(mockOnUpdate.mock.calls[0][0]).toEqual( + expect.objectContaining({ description: storedDescription }), + ); + }); + it('renders a split save button when allows_virtual_table_explore is enabled', async () => { render(, { useRedux: true, diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx index 0054867893e..04b1522c9cb 100644 --- a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx +++ b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx @@ -171,16 +171,22 @@ const SaveQuery = ({
- - + +
- +