Skip to content

Commit

Permalink
fix: Columns not passing properly from SQL Lab to Explore (#20975)
Browse files Browse the repository at this point in the history
* debugging columns

* Clean up code

* Fix test
  • Loading branch information
lyndsiWilliams committed Aug 4, 2022
1 parent 755f654 commit d42cf4e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('SavedQuery', () => {
const closeBtn = screen.getByRole('button', { name: /close/i });
const saveDatasetHeader = screen.getByText(/save or overwrite dataset/i);
const saveRadio = screen.getByRole('radio', {
name: /save as new untitled dataset/i,
name: /save as new untitled/i,
});
const saveLabel = screen.getByText(/save as new/i);
const saveTextbox = screen.getByRole('textbox');
Expand Down
5 changes: 3 additions & 2 deletions superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import { Form, FormItem } from 'src/components/Form';
import Modal from 'src/components/Modal';
import SaveDatasetActionButton from 'src/SqlLab/components/SaveDatasetActionButton';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
import { getDatasourceAsSaveableDataset } from 'src/utils/datasourceUtils';

interface SaveQueryProps {
query: any;
query: QueryPayload;
defaultLabel: string;
onSave: (arg0: QueryPayload) => void;
onUpdate: (arg0: QueryPayload) => void;
Expand Down Expand Up @@ -177,7 +178,7 @@ export default function SaveQuery({
onHide={() => setShowSaveDatasetModal(false)}
buttonTextOnSave={t('Save & Explore')}
buttonTextOnOverwrite={t('Overwrite & Explore')}
datasource={query}
datasource={getDatasourceAsSaveableDataset(query)}
/>
<Modal
className="save-query-modal"
Expand Down
5 changes: 4 additions & 1 deletion superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,10 @@ class SqlEditor extends React.PureComponent {
<div className="rightItems">
<span>
<SaveQuery
query={qe}
query={{
...qe,
columns: this.props.latestQuery?.results?.columns || [],
}}
defaultLabel={qe.name || qe.description}
onSave={this.saveQuery}
onUpdate={this.props.actions.updateSavedQuery}
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/utils/datasourceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
export const getDatasourceAsSaveableDataset = source => ({
columns: source.columns,
name: source?.datasource_name || source?.name || 'Untitled',
dbId: source.database.id,
dbId: source?.database?.id || source?.dbId,
sql: source?.sql || '',
schema: source?.schema,
});

0 comments on commit d42cf4e

Please sign in to comment.