Skip to content

Commit

Permalink
[#730] Make sure 'sort' is always in package_search's data_dict
Browse files Browse the repository at this point in the history
If data_dict contained no 'sort', the default value was not being added
if the data_dict did contain 'abort_search': True. The code nonetheless
tries to access data_dict['sort'] later on and crashes. (Isn't this what
schemas and validation are supposed to be for?) This was causing a test
to fail. Adding the default 'sort' value to data_dict even if
'abort_search': True is there fixes it.
  • Loading branch information
Sean Hammond committed Apr 16, 2013
1 parent 6bc544c commit e43dae5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ckan/logic/action/get.py
Expand Up @@ -1234,6 +1234,9 @@ def package_search(context, data_dict):
# the query
abort = data_dict.get('abort_search',False)

if data_dict.get('sort') in (None, 'rank'):
data_dict['sort'] = 'relevance asc, metadata_modified desc'

results = []
if not abort:
# return a list of package ids
Expand All @@ -1249,9 +1252,6 @@ def package_search(context, data_dict):
if not 'capacity:' in p)
data_dict['fq'] = fq + ' capacity:"public"'

if data_dict.get('sort') in (None, 'rank'):
data_dict['sort'] = 'relevance asc, metadata_modified desc'

query = search.query_for(model.Package)
query.run(data_dict)

Expand Down

0 comments on commit e43dae5

Please sign in to comment.