Skip to content

Commit

Permalink
Merge pull request #300 from ckan/sqlalchemy2
Browse files Browse the repository at this point in the history
SQLAlchemy v2 support
  • Loading branch information
amercader committed Sep 9, 2024
2 parents cde864e + 1349cb3 commit cb25389
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ckanext/dcat/harvesters/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uuid

import requests
import sqlalchemy as sa

from ckan import model
from ckan import logic
Expand Down Expand Up @@ -273,7 +274,8 @@ def import_stage(self, harvest_object):
# the harvest object id (on the after_show hook from the harvester
# plugin)
model.Session.execute(
'SET CONSTRAINTS harvest_object_package_id_fkey DEFERRED')
sa.text('SET CONSTRAINTS harvest_object_package_id_fkey DEFERRED')
)
model.Session.flush()

elif status == 'change':
Expand Down
8 changes: 6 additions & 2 deletions ckanext/dcat/harvesters/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import hashlib
import traceback

import sqlalchemy as sa

import ckan.plugins as p
import ckan.model as model

Expand Down Expand Up @@ -278,7 +280,7 @@ def import_stage(self, harvest_object):
harvest_object.guid))
except p.toolkit.ObjectNotFound:
log.info('Package {0} already deleted.'.format(harvest_object.package_id))

return True

if harvest_object.content is None:
Expand Down Expand Up @@ -392,7 +394,9 @@ def import_stage(self, harvest_object):
# Defer constraints and flush so the dataset can be indexed with
# the harvest object id (on the after_show hook from the harvester
# plugin)
model.Session.execute('SET CONSTRAINTS harvest_object_package_id_fkey DEFERRED')
model.Session.execute(
sa.text('SET CONSTRAINTS harvest_object_package_id_fkey DEFERRED')
)
model.Session.flush()

p.toolkit.get_action('package_create')(context, dataset)
Expand Down

0 comments on commit cb25389

Please sign in to comment.