Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: when max_age is None the handler fails #3462

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions redash/handlers/query_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def run_query_sync(data_source, parameter_values, query_text, max_age=0):

run_time = time.time() - started_at
query_result, updated_query_ids = models.QueryResult.store_result(data_source.org_id, data_source,
query_hash, query.text, data,
run_time, utcnow())
query_hash, query.text, data,
run_time, utcnow())
models.db.session.commit()
return query_result
except Exception as e:
Expand Down Expand Up @@ -108,7 +108,11 @@ def post(self):
params = request.get_json(force=True)

query = params['query']
max_age = int(params.get('max_age', -1))
max_age = params.get('max_age', -1)
# max_age might have the value of None, in which case calling int(None) will fail
if max_age is None:
max_age = -1
max_age = int(max_age)
query_id = params.get('query_id', 'adhoc')
parameters = params.get('parameters', collect_parameters_from_request(request.args))

Expand Down