Skip to content

Commit

Permalink
Return original state for query if query was stopped (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
vera-liu authored Feb 14, 2017
1 parent a5a931a commit 527a8af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions superset/assets/javascripts/SqlLab/components/ResultSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class ResultSet extends React.PureComponent {

let sql;

if (query.state === 'stopped') {
return <Alert bsStyle="warning">Query was stopped</Alert>;
}

if (this.props.showSql) {
sql = <HighlightedSql sql={query.sql} />;
}
Expand Down
13 changes: 10 additions & 3 deletions superset/assets/javascripts/SqlLab/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const sqlLabReducer = function (state, action) {
return alterInArr(newState, 'queryEditors', sqlEditor, { latestQueryId: action.query.id });
},
[actions.STOP_QUERY]() {
return alterInObject(state, 'queries', action.query, { state: 'stopped' });
return alterInObject(state, 'queries', action.query, { state: 'stopped', results: [] });
},
[actions.CLEAR_QUERY_RESULTS]() {
const newResults = Object.assign({}, action.query.results);
Expand All @@ -162,6 +162,9 @@ export const sqlLabReducer = function (state, action) {
return alterInObject(state, 'queries', action.query, { state: 'fetching' });
},
[actions.QUERY_SUCCESS]() {
if (action.query.state === 'stopped') {
return state;
}
let rows;
if (action.results.data) {
rows = action.results.data.length;
Expand All @@ -178,6 +181,9 @@ export const sqlLabReducer = function (state, action) {
return alterInObject(state, 'queries', action.query, alts);
},
[actions.QUERY_FAILED]() {
if (action.query.state === 'stopped') {
return state;
}
const alts = { state: 'failed', errorMessage: action.msg, endDttm: now() };
return alterInObject(state, 'queries', action.query, alts);
},
Expand Down Expand Up @@ -237,8 +243,9 @@ export const sqlLabReducer = function (state, action) {
for (const id in action.alteredQueries) {
const changedQuery = action.alteredQueries[id];
if (
!state.queries.hasOwnProperty(id) ||
state.queries[id].changedOn !== changedQuery.changedOn) {
state.queries[id].state !== 'stopped' &&
(!state.queries.hasOwnProperty(id) ||
state.queries[id].changedOn !== changedQuery.changedOn)) {
newQueries[id] = Object.assign({}, state.queries[id], changedQuery);
change = true;
}
Expand Down

0 comments on commit 527a8af

Please sign in to comment.