You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2019/05/31 22:26:51 UTC

[incubator-superset] branch master updated: [SQL Lab] Old query showing success state but not showing results (#7628)

This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 5701629  [SQL Lab] Old query showing success state but not showing results (#7628)
5701629 is described below

commit 5701629d952c0e51a74f48871b3988f586b289b6
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Fri May 31 15:26:41 2019 -0700

    [SQL Lab] Old query showing success state but not showing results (#7628)
---
 superset/assets/spec/javascripts/sqllab/SouthPane_spec.jsx | 14 +++++++++++++-
 superset/assets/src/SqlLab/components/SouthPane.jsx        |  4 +++-
 superset/assets/src/SqlLab/components/SqlEditor.jsx        |  1 +
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/superset/assets/spec/javascripts/sqllab/SouthPane_spec.jsx b/superset/assets/spec/javascripts/sqllab/SouthPane_spec.jsx
index da6da52..7baba2b 100644
--- a/superset/assets/spec/javascripts/sqllab/SouthPane_spec.jsx
+++ b/superset/assets/spec/javascripts/sqllab/SouthPane_spec.jsx
@@ -25,6 +25,7 @@ import { shallow } from 'enzyme';
 import { STATUS_OPTIONS } from '../../../src/SqlLab/constants';
 import { initialState } from './fixtures';
 import SouthPaneContainer, { SouthPane } from '../../../src/SqlLab/components/SouthPane';
+import ResultSet from '../../../src/SqlLab/components/ResultSet';
 
 describe('SouthPane', () => {
   const middlewares = [thunk];
@@ -32,7 +33,13 @@ describe('SouthPane', () => {
   const store = mockStore(initialState);
 
   const mockedProps = {
-    editorQueries: [],
+    editorQueries: [
+      { cached: false, changedOn: 1559238552333, db: 'main', dbId: 1, id: 'LCly_kkIN' },
+      { cached: false, changedOn: 1559238500401, db: 'main', dbId: 1, id: 'lXJa7F9_r' },
+      { cached: false, changedOn: 1559238506925, db: 'main', dbId: 1, id: '2g2_iRFMl' },
+      { cached: false, changedOn: 1559238516395, db: 'main', dbId: 1, id: 'erWdqEWPm' },
+    ],
+    latestQueryId: 'LCly_kkIN',
     dataPreviewQueries: [],
     actions: {},
     activeSouthPaneTab: '',
@@ -57,4 +64,9 @@ describe('SouthPane', () => {
     wrapper.setProps({ offline: true });
     expect(wrapper.find('.m-r-3').render().text()).toBe(STATUS_OPTIONS.offline);
   });
+  it('should pass latest query down to ResultSet component', () => {
+    wrapper = getWrapper();
+    expect(wrapper.find(ResultSet)).toHaveLength(1);
+    expect(wrapper.find(ResultSet).props().query.id).toEqual(mockedProps.latestQueryId);
+  });
 });
diff --git a/superset/assets/src/SqlLab/components/SouthPane.jsx b/superset/assets/src/SqlLab/components/SouthPane.jsx
index c3dd57b..68321f3 100644
--- a/superset/assets/src/SqlLab/components/SouthPane.jsx
+++ b/superset/assets/src/SqlLab/components/SouthPane.jsx
@@ -37,6 +37,7 @@ const TAB_HEIGHT = 44;
 */
 const propTypes = {
   editorQueries: PropTypes.array.isRequired,
+  latestQueryId: PropTypes.string.isRequired,
   dataPreviewQueries: PropTypes.array.isRequired,
   actions: PropTypes.object.isRequired,
   activeSouthPaneTab: PropTypes.string,
@@ -82,7 +83,8 @@ export class SouthPane extends React.PureComponent {
     let latestQuery;
     const props = this.props;
     if (props.editorQueries.length > 0) {
-      latestQuery = props.editorQueries[props.editorQueries.length - 1];
+      // get the latest query
+      latestQuery = props.editorQueries.find(q => q.id === this.props.latestQueryId);
     }
     let results;
     if (latestQuery) {
diff --git a/superset/assets/src/SqlLab/components/SqlEditor.jsx b/superset/assets/src/SqlLab/components/SqlEditor.jsx
index 84e5106..87930d9 100644
--- a/superset/assets/src/SqlLab/components/SqlEditor.jsx
+++ b/superset/assets/src/SqlLab/components/SqlEditor.jsx
@@ -306,6 +306,7 @@ class SqlEditor extends React.PureComponent {
         </div>
         <SouthPane
           editorQueries={this.props.editorQueries}
+          latestQueryId={this.props.latestQuery ? this.props.latestQuery.id : 0}
           dataPreviewQueries={this.props.dataPreviewQueries}
           actions={this.props.actions}
           height={southPaneHeight}