Skip to content

Commit

Permalink
Merge pull request getredash#432 from stanhu/allow-undefined-max-age
Browse files Browse the repository at this point in the history
Allow undefined max_age parameter in query_results endpoint
  • Loading branch information
arikfr committed May 15, 2015
2 parents 20eb110 + 690f832 commit 105971c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions redash/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def delete(self, visualization_id):
class QueryResultListAPI(BaseResource):
@require_permission('execute_query')
def post(self):
params = request.json
params = request.get_json(force=True)

if settings.FEATURE_TABLES_PERMISSIONS:
metadata = utils.SQLMetaData(params['query'])
Expand All @@ -476,7 +476,7 @@ def post(self):
activity=params['query']
).save()

max_age = int(params['max_age'])
max_age = int(params.get('max_age', -1))

if max_age == 0:
query_result = None
Expand Down
11 changes: 11 additions & 0 deletions tests/test_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,17 @@ def setUp(self):
self.paths = []
super(QueryResultAPITest, self).setUp()

def test_post_result_list(self):
data_source = data_source_factory.create()
query_result = query_result_factory.create()
query = query_factory.create()

with app.test_client() as c, authenticated_user(c):
rv = json_request(c.post, '/api/query_results',
data={'data_source_id': data_source.id,
'query': query.query})
self.assertEquals(rv.status_code, 200)


class JobAPITest(BaseTestCase, AuthenticationTestMixin):
def setUp(self):
Expand Down

0 comments on commit 105971c

Please sign in to comment.