[sqllab] Fixed js error when results are not available (#1715)

* Fixed js error when results are not available

* Flush data and query in results when running new query, keeping columns

* add exception for columns

* Move setState from componentWillMount to componentWillReceiveProps

* Nit
This commit is contained in:
vera-liu
2016-12-05 13:36:18 -08:00
committed by GitHub
parent d8864bc92b
commit eb0655cf85
3 changed files with 23 additions and 14 deletions

View File

@@ -134,8 +134,10 @@ export const sqlLabReducer = function (state, action) {
let newState = Object.assign({}, state);
if (action.query.sqlEditorId) {
const qe = getFromArr(state.queryEditors, action.query.sqlEditorId);
if (qe.latestQueryId) {
const q = Object.assign({}, state.queries[qe.latestQueryId], { results: null });
if (qe.latestQueryId && state.queries[qe.latestQueryId]) {
const newResults = Object.assign(
{}, state.queries[qe.latestQueryId].results, { data: [], query: null });
const q = Object.assign({}, state.queries[qe.latestQueryId], { results: newResults });
const queries = Object.assign({}, state.queries, { [q.id]: q });
newState = Object.assign({}, state, { queries });
}