Skip to content

Commit

Permalink
Do not update extra in pkg_dict if it already exist.
Browse files Browse the repository at this point in the history
This is a responsibility of the package. We are skiping any override since users will expect the behaviour of the custom logic added in package schema and validators.
  • Loading branch information
pdelboca committed Mar 13, 2023
1 parent 62a16d0 commit 10c2fec
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ckanext/harvest/plugin/__init__.py
Expand Up @@ -138,8 +138,11 @@ def before_dataset_index(self, pkg_dict):
already exist in the root schema.
Note: If another extension adds any harvest extra to the `package_show`
schema then this method will add them again in the `extras` field to avoid
schema then this method will not add them again in the `extras` field to avoid
validation errors when updating a package.
If the harvest extra has been added to the root schema, then we will not update
them since it is responsibility of the package validators to do it.
"""
# Fix to support Solr8
if isinstance(pkg_dict.get('status'), dict):
Expand Down Expand Up @@ -180,7 +183,8 @@ def before_dataset_index(self, pkg_dict):

# Add harvest extras to main indexed pkg_dict
for key, value in harvest_extras:
pkg_dict[key] = value
if key not in pkg_dict.keys():
pkg_dict[key] = value

pkg_dict["data_dict"] = json.dumps(data_dict)
pkg_dict["validated_data_dict"] = json.dumps(validated_data_dict)
Expand Down

0 comments on commit 10c2fec

Please sign in to comment.