Skip to content

Commit

Permalink
Fix version check
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Dec 16, 2024
1 parent 0d64786 commit 6bcf693
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ckanext/dcat/harvesters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,21 @@ def _read_datasets_from_db(self, guid):
'''
Returns a database result of datasets matching the given guid.
'''
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()
if toolkit.check_ckan_version(max_version="2.11.99"):
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()
)

return datasets

Expand Down

0 comments on commit 6bcf693

Please sign in to comment.