Skip to content

Commit

Permalink
fix(sqllab): Add templateParams on kv store (#22013)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Nov 14, 2022
1 parent 86d52fc commit c3f1873
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ export function popStoredQuery(urlId) {
schema: json.schema ? json.schema : null,
autorun: json.autorun ? json.autorun : false,
sql: json.sql ? json.sql : 'SELECT ...',
templateParams: json.templateParams,
}),
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const unsavedQueryEditor = {
schema: 'query_schema_updated',
sql: 'SELECT * FROM Updated Limit 100',
autorun: true,
templateParams: '{ "my_value": "foo" }',
};

const standardProviderWithUnsaved: React.FC = ({ children }) => (
Expand Down
16 changes: 11 additions & 5 deletions superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ function ShareSqlLabQuery({
}: ShareSqlLabQueryPropTypes) {
const theme = useTheme();

const { dbId, name, schema, autorun, sql, remoteId } = useQueryEditor(
queryEditorId,
['dbId', 'name', 'schema', 'autorun', 'sql', 'remoteId'],
);
const { dbId, name, schema, autorun, sql, remoteId, templateParams } =
useQueryEditor(queryEditorId, [
'dbId',
'name',
'schema',
'autorun',
'sql',
'remoteId',
'templateParams',
]);

const getCopyUrlForKvStore = (callback: Function) => {
const sharedQuery = { dbId, name, schema, autorun, sql };
const sharedQuery = { dbId, name, schema, autorun, sql, templateParams };

return storeQuery(sharedQuery)
.then(shortUrl => {
Expand Down

0 comments on commit c3f1873

Please sign in to comment.