superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michel...@apache.org
Subject [incubator-superset] 02/08: [SQL Lab] Old query showing success state but not showing results (#7628)
Date Sat, 08 Jun 2019 01:00:01 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 9fdbfcdd52e16b533042f0f1921d8cf7a3c304cc
Author: Grace Guo <grace.guo@airbnb.com>
AuthorDate: Fri May 31 15:26:41 2019 -0700

    [SQL Lab] Old query showing success state but not showing results (#7628)
    
    
    (cherry picked from commit 5701629d952c0e51a74f48871b3988f586b289b6)
---
 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 960a4af..0005ec4 100644
--- a/superset/assets/src/SqlLab/components/SqlEditor.jsx
+++ b/superset/assets/src/SqlLab/components/SqlEditor.jsx
@@ -247,6 +247,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={this.state.southPaneHeight || southPaneHeight}


Mime
View raw message