Skip to content

Commit

Permalink
PackageExtra no longer available on CKAN>2.11
Browse files Browse the repository at this point in the history
Need to use Package.extras instead

ckan/ckan#8288
  • Loading branch information
amercader committed Aug 26, 2024
1 parent d00cbd6 commit edfad24
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ckanext/dcat/harvesters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,18 @@ def _read_datasets_from_db(self, guid):
'''
Returns a database result of datasets matching the given guid.
'''
if toolkit.check_ckan_version(max_version="2.11"):
datasets = model.Session.query(model.Package.id) \
.join(model.PackageExtra) \
.filter(model.PackageExtra.key == 'guid') \
.filter(model.PackageExtra.value == guid) \
.filter(model.Package.state == 'active') \
.all()
else:
datasets = model.Session.query(model.Package.id) \
.filter(model.Package.extras['guid'] == f'"{guid}"') \
.all()

datasets = model.Session.query(model.Package.id) \
.join(model.PackageExtra) \
.filter(model.PackageExtra.key == 'guid') \
.filter(model.PackageExtra.value == guid) \
.filter(model.Package.state == 'active') \
.all()
return datasets

def _get_existing_dataset(self, guid):
Expand Down

0 comments on commit edfad24

Please sign in to comment.