Skip to content

Commit

Permalink
[#1251] Allow datastore search to be able to take lists to generage i…
Browse files Browse the repository at this point in the history
…n statements
  • Loading branch information
kindly committed Mar 18, 2014
1 parent 66f8245 commit d5593d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ckan/tests/logic/test_action.py
Expand Up @@ -1396,6 +1396,8 @@ def test_resource_view_create(self):
resource_view_created = json.loads(res.body)['result']

resource_view_created.pop('id')
resource_view_created.pop('package_id')

assert len(resource_view) == len(resource_view_created)
for field in resource_view:
assert resource_view[field] == resource_view_created[field], \
Expand Down Expand Up @@ -1468,6 +1470,7 @@ def test_resource_view_show(self):
result = json.loads(res.body)['result']

result.pop('id')
result.pop('package_id')
assert result == resource_view

def test_resource_view_list_reorder(self):
Expand Down Expand Up @@ -1571,6 +1574,7 @@ def test_resource_view_update(self):
extra_environ={'Authorization': str(self.normal_user.apikey)})
result = json.loads(res.body)['result']

result.pop('package_id')
assert result == resource_view

def test_resource_view_update_missing_resource_view_id(self):
Expand Down
9 changes: 9 additions & 0 deletions ckanext/datastore/db.py
Expand Up @@ -762,6 +762,15 @@ def _where(field_ids, data_dict):
raise ValidationError({
'filters': ['field "{0}" not in table'.format(field)]}
)

if isinstance(value, list):
where_clauses.append(
u'"{0}" in ({1})'.format(field,
','.join(['%s'] * len(value)))
)
values.extend(value)
continue

where_clauses.append(u'"{0}" = %s'.format(field))
values.append(value)

Expand Down

0 comments on commit d5593d7

Please sign in to comment.