Skip to content

Commit

Permalink
[explore] fix empty query message in 'View Query' (apache#4273)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored and john-bodley committed Jan 24, 2018
1 parent a4a2f6c commit 1aecb1d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,16 +988,22 @@ def slice(self, slice_id):
return redirect(endpoint)

def get_query_string_response(self, viz_obj):
query = None
try:
query_obj = viz_obj.query_obj()
query = viz_obj.datasource.get_query_str(query_obj)
if query_obj:
query = viz_obj.datasource.get_query_str(query_obj)
except Exception as e:
logging.exception(e)
return json_error_response(e)

if query_obj['prequeries']:
if query_obj and query_obj['prequeries']:
query_obj['prequeries'].append(query)
query = ';\n\n'.join(query_obj['prequeries'])
query += ';'
if query:
query += ';'
else:
query = 'No query.'

return Response(
json.dumps({
Expand Down Expand Up @@ -1100,9 +1106,10 @@ def explore_json(self, datasource_type, datasource_id):
force = request.args.get('force') == 'true'
form_data = self.get_form_data()
except Exception as e:
return json_error_response(
utils.error_msg_from_exception(e),
stacktrace=traceback.format_exc())
logging.exception(e)
return json_error_response(
utils.error_msg_from_exception(e),
stacktrace=traceback.format_exc())
return self.generate_json(datasource_type=datasource_type,
datasource_id=datasource_id,
form_data=form_data,
Expand Down

0 comments on commit 1aecb1d

Please sign in to comment.