Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: saving a new query removes reference to last query result #3421

Merged
merged 3 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/app/pages/queries/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ function QueryViewCtrl(
}

if (status === 'done') {
const ranSelectedQuery = $scope.query.query !== $scope.queryResult.query;
const ranSelectedQuery = $scope.query.query !== $scope.queryResult.query_result.query;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix.

if (!ranSelectedQuery) {
$scope.query.latest_query_data_id = $scope.queryResult.getId();
$scope.query.queryResult = $scope.queryResult;
Expand Down Expand Up @@ -445,6 +445,9 @@ function QueryViewCtrl(
$scope.saveQuery().then((query) => {
// Because we have a path change, we need to "signal" the next page to
// open the visualization editor.
// TODO: we don't really need this. Just need to assign query to $scope.query
// and maybe a few more small changes. Not worth handling this now, but also
// we shouldn't copy this bizzare method to the React codebase.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for future generations.

$location.path(query.getSourceLink()).hash('add');
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion redash/handlers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def post(self):
'object_type': 'query'
})

return QuerySerializer(query).serialize()
return QuerySerializer(query, with_visualizations=True).serialize()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be needed when we implement new query save and open visualization editor the right way.



class QueryArchiveResource(BaseQueryListResource):
Expand Down