mirror of
https://github.com/apache/superset.git
synced 2026-04-21 09:04:38 +00:00
feat(sqllab): save query parameters in database (#21682)
This commit is contained in:
@@ -36,8 +36,8 @@ import { QueryEditor } from 'src/SqlLab/types';
|
||||
interface SaveQueryProps {
|
||||
queryEditorId: string;
|
||||
columns: ISaveableDatasource['columns'];
|
||||
onSave: (arg0: QueryPayload) => void;
|
||||
onUpdate: (arg0: QueryPayload) => void;
|
||||
onSave: (arg0: QueryPayload, id: string) => void;
|
||||
onUpdate: (arg0: QueryPayload, id: string) => void;
|
||||
saveQueryWarning: string | null;
|
||||
database: Record<string, any>;
|
||||
}
|
||||
@@ -46,19 +46,8 @@ type QueryPayload = {
|
||||
name: string;
|
||||
description?: string;
|
||||
id?: string;
|
||||
} & Pick<
|
||||
QueryEditor,
|
||||
| 'autorun'
|
||||
| 'dbId'
|
||||
| 'schema'
|
||||
| 'sql'
|
||||
| 'selectedText'
|
||||
| 'remoteId'
|
||||
| 'latestQueryId'
|
||||
| 'queryLimit'
|
||||
| 'tableOptions'
|
||||
| 'schemaOptions'
|
||||
>;
|
||||
remoteId?: number;
|
||||
} & Pick<QueryEditor, 'dbId' | 'schema' | 'sql'>;
|
||||
|
||||
const Styles = styled.span`
|
||||
span[role='img'] {
|
||||
@@ -93,11 +82,11 @@ export default function SaveQuery({
|
||||
'selectedText',
|
||||
'sql',
|
||||
'tableOptions',
|
||||
'templateParams',
|
||||
]);
|
||||
const query = useMemo(
|
||||
() => ({
|
||||
...queryEditor,
|
||||
columns,
|
||||
}),
|
||||
[queryEditor, columns],
|
||||
);
|
||||
@@ -120,10 +109,13 @@ export default function SaveQuery({
|
||||
);
|
||||
|
||||
const queryPayload = () => ({
|
||||
...query,
|
||||
name: label,
|
||||
description,
|
||||
dbId: query.dbId ?? 0,
|
||||
sql: query.sql,
|
||||
schema: query.schema,
|
||||
templateParams: query.templateParams,
|
||||
remoteId: query?.remoteId || undefined,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -133,12 +125,12 @@ export default function SaveQuery({
|
||||
const close = () => setShowSave(false);
|
||||
|
||||
const onSaveWrapper = () => {
|
||||
onSave(queryPayload());
|
||||
onSave(queryPayload(), query.id);
|
||||
close();
|
||||
};
|
||||
|
||||
const onUpdateWrapper = () => {
|
||||
onUpdate(queryPayload());
|
||||
onUpdate(queryPayload(), query.id);
|
||||
close();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user