Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLAlchemy v2 support #300

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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