diff --git a/ckan/logic/action/patch.py b/ckan/logic/action/patch.py index b0ed4f6819e..6d8ebfb5ed4 100644 --- a/ckan/logic/action/patch.py +++ b/ckan/logic/action/patch.py @@ -1,7 +1,11 @@ '''API functions for partial updates of existing data in CKAN''' import ckan.logic.action.update as _update -from ckan.logic import get_action as _get_action, check_access as _check_access +from ckan.logic import ( + get_action as _get_action, + check_access as _check_access, + get_or_bust as _get_or_bust, +) def package_patch(context, data_dict): @@ -19,7 +23,6 @@ def package_patch(context, data_dict): _check_access('package_patch', context, data_dict) - name_or_id = data_dict.get("name") or _get_or_bust(data_dict, "id") show_context = { 'model': context['model'], 'session': context['session'], @@ -29,7 +32,7 @@ def package_patch(context, data_dict): package_dict = _get_action('package_show')( show_context, - {'id': name_or_id}) + {'id': _get_or_bust(data_dict, 'id')}) patched = dict(package_dict.items() + data_dict.items()) return _update.package_update(context, patched) diff --git a/ckan/new_tests/logic/action/test_patch.py b/ckan/new_tests/logic/action/test_patch.py index 8c11c4e043f..48a9970e39f 100644 --- a/ckan/new_tests/logic/action/test_patch.py +++ b/ckan/new_tests/logic/action/test_patch.py @@ -25,6 +25,7 @@ def test_package_patch_updating_single_field(self): assert_equals(dataset['name'], 'somethingnew') assert_equals(dataset['notes'], 'some test now') - assert_equals( - helpers.call_action('package_show', id='somethingnew')['notes'], - 'some test now') + dataset2 = helpers.call_action('package_show', id=dataset['id']) + + assert_equals(dataset2['name'], 'somethingnew') + assert_equals(dataset2['notes'], 'some test now')