mirror of https://github.com/apache/superset.git
fix: Columns not passing properly from SQL Lab to Explore (#20975)
* debugging columns * Clean up code * Fix test
This commit is contained in:
parent
755f654cc6
commit
d42cf4e4c9
|
@ -159,7 +159,7 @@ describe('SavedQuery', () => {
|
||||||
const closeBtn = screen.getByRole('button', { name: /close/i });
|
const closeBtn = screen.getByRole('button', { name: /close/i });
|
||||||
const saveDatasetHeader = screen.getByText(/save or overwrite dataset/i);
|
const saveDatasetHeader = screen.getByText(/save or overwrite dataset/i);
|
||||||
const saveRadio = screen.getByRole('radio', {
|
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 saveLabel = screen.getByText(/save as new/i);
|
||||||
const saveTextbox = screen.getByRole('textbox');
|
const saveTextbox = screen.getByRole('textbox');
|
||||||
|
|
|
@ -26,9 +26,10 @@ import { Form, FormItem } from 'src/components/Form';
|
||||||
import Modal from 'src/components/Modal';
|
import Modal from 'src/components/Modal';
|
||||||
import SaveDatasetActionButton from 'src/SqlLab/components/SaveDatasetActionButton';
|
import SaveDatasetActionButton from 'src/SqlLab/components/SaveDatasetActionButton';
|
||||||
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
|
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
|
||||||
|
import { getDatasourceAsSaveableDataset } from 'src/utils/datasourceUtils';
|
||||||
|
|
||||||
interface SaveQueryProps {
|
interface SaveQueryProps {
|
||||||
query: any;
|
query: QueryPayload;
|
||||||
defaultLabel: string;
|
defaultLabel: string;
|
||||||
onSave: (arg0: QueryPayload) => void;
|
onSave: (arg0: QueryPayload) => void;
|
||||||
onUpdate: (arg0: QueryPayload) => void;
|
onUpdate: (arg0: QueryPayload) => void;
|
||||||
|
@ -177,7 +178,7 @@ export default function SaveQuery({
|
||||||
onHide={() => setShowSaveDatasetModal(false)}
|
onHide={() => setShowSaveDatasetModal(false)}
|
||||||
buttonTextOnSave={t('Save & Explore')}
|
buttonTextOnSave={t('Save & Explore')}
|
||||||
buttonTextOnOverwrite={t('Overwrite & Explore')}
|
buttonTextOnOverwrite={t('Overwrite & Explore')}
|
||||||
datasource={query}
|
datasource={getDatasourceAsSaveableDataset(query)}
|
||||||
/>
|
/>
|
||||||
<Modal
|
<Modal
|
||||||
className="save-query-modal"
|
className="save-query-modal"
|
||||||
|
|
|
@ -721,7 +721,10 @@ class SqlEditor extends React.PureComponent {
|
||||||
<div className="rightItems">
|
<div className="rightItems">
|
||||||
<span>
|
<span>
|
||||||
<SaveQuery
|
<SaveQuery
|
||||||
query={qe}
|
query={{
|
||||||
|
...qe,
|
||||||
|
columns: this.props.latestQuery?.results?.columns || [],
|
||||||
|
}}
|
||||||
defaultLabel={qe.name || qe.description}
|
defaultLabel={qe.name || qe.description}
|
||||||
onSave={this.saveQuery}
|
onSave={this.saveQuery}
|
||||||
onUpdate={this.props.actions.updateSavedQuery}
|
onUpdate={this.props.actions.updateSavedQuery}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
export const getDatasourceAsSaveableDataset = source => ({
|
export const getDatasourceAsSaveableDataset = source => ({
|
||||||
columns: source.columns,
|
columns: source.columns,
|
||||||
name: source?.datasource_name || source?.name || 'Untitled',
|
name: source?.datasource_name || source?.name || 'Untitled',
|
||||||
dbId: source.database.id,
|
dbId: source?.database?.id || source?.dbId,
|
||||||
sql: source?.sql || '',
|
sql: source?.sql || '',
|
||||||
schema: source?.schema,
|
schema: source?.schema,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue