Skip to content

Commit

Permalink
Bug fix] Saving a new query removes reference to last query result (#…
Browse files Browse the repository at this point in the history
…3421)

* Correctly test if the current query result is for the current query.
* Serialize a new query with its visualizations.
  • Loading branch information
arikfr authored and kravets-levko committed Feb 11, 2019
1 parent eee77a1 commit cb22764
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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;
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.
$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()


class QueryArchiveResource(BaseQueryListResource):
Expand Down

0 comments on commit cb22764

Please sign in to comment.