From 9fb7aa1cd584ec3e6cb9220515f79eb93df3e53b Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Sat, 7 Sep 2024 23:11:50 +0300 Subject: [PATCH] feat: SQLAlchemy v2 support --- ckanext/spatial/harvesters/base.py | 5 ++++- ckanext/spatial/util.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ckanext/spatial/harvesters/base.py b/ckanext/spatial/harvesters/base.py index ecf5e67a..f750395f 100644 --- a/ckanext/spatial/harvesters/base.py +++ b/ckanext/spatial/harvesters/base.py @@ -16,6 +16,7 @@ from owslib import wms import requests +import sqlalchemy as sa from lxml import etree from ckan import plugins as p @@ -667,7 +668,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() try: diff --git a/ckanext/spatial/util.py b/ckanext/spatial/util.py index fc822d2e..cbc6bd7e 100644 --- a/ckanext/spatial/util.py +++ b/ckanext/spatial/util.py @@ -12,7 +12,6 @@ from pprint import pprint from ckan import model -from ckan.model.package_extra import PackageExtra try: from ckanext.spatial.lib.reports import validation_report