Skip to content

Commit

Permalink
Use POST in sqllab_viz instead of url params to avoid error with long…
Browse files Browse the repository at this point in the history
… queries (#1933)

* Use POST in sqllab_viz instead of url params to avoid error with long queries

* Delete error handling

* Fix returning statement
  • Loading branch information
vera-liu authored Jan 11, 2017
1 parent f0917c6 commit a385ee9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 12 additions & 1 deletion superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Alert, Button, Col, Modal } from 'react-bootstrap';
import Select from 'react-select';
import { Table } from 'reactable';
import shortid from 'shortid';
import $ from 'jquery';

const CHART_TYPES = [
{ value: 'dist_bar', label: 'Distribution - Bar Chart', requiresTime: false },
Expand Down Expand Up @@ -105,7 +106,17 @@ class VisualizeModal extends React.PureComponent {
sql: this.props.query.sql,
dbId: this.props.query.dbId,
};
window.open('/superset/sqllab_viz/?data=' + JSON.stringify(vizOptions));
$.ajax({
type: 'POST',
url: '/superset/sqllab_viz/',
async: false,
data: {
data: JSON.stringify(vizOptions),
},
success: (url) => {
window.open(url);
},
});
}
changeDatasourceName(event) {
this.setState({ datasourceName: event.target.value });
Expand Down
7 changes: 3 additions & 4 deletions superset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2222,10 +2222,10 @@ def sync_druid_source(self):
return Response(status=201)

@has_access
@expose("/sqllab_viz/")
@expose("/sqllab_viz/", methods=['POST'])
@log_this
def sqllab_viz(self):
data = json.loads(request.args.get('data'))
data = json.loads(request.form.get('data'))
table_name = data.get('datasourceName')
viz_type = data.get('chartType')
table = (
Expand Down Expand Up @@ -2283,8 +2283,7 @@ def sqllab_viz(self):
'limit': '0',
}
params = "&".join([k + '=' + v for k, v in params.items() if v])
url = '/superset/explore/table/{table.id}/?{params}'.format(**locals())
return redirect(url)
return '/superset/explore/table/{table.id}/?{params}'.format(**locals())

@has_access
@expose("/table/<database_id>/<table_name>/<schema>/")
Expand Down

0 comments on commit a385ee9

Please sign in to comment.