From dd60b8924d03e422020506864b084248f3a398ce Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 25 Apr 2023 10:41:37 +0200 Subject: [PATCH] Wrap the `PRAGMA` statement in `sqlalchemy.text`. SQLAlchemy 2 no longer supports raw strings passed to `.execute()` methods. --- platypush/plugins/entities/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/entities/__init__.py b/platypush/plugins/entities/__init__.py index 443cf51ab2..74caf3cd5a 100644 --- a/platypush/plugins/entities/__init__.py +++ b/platypush/plugins/entities/__init__.py @@ -3,7 +3,7 @@ from threading import Thread from time import time from typing import Optional, Any, Collection, Mapping -from sqlalchemy import or_ +from sqlalchemy import or_, text from sqlalchemy.orm import make_transient, Session from platypush.config import Config @@ -198,7 +198,7 @@ class EntitiesPlugin(Plugin): if str(session.connection().engine.url).startswith('sqlite://'): # SQLite requires foreign_keys to be explicitly enabled # in order to proper manage cascade deletions - session.execute('PRAGMA foreign_keys = ON') + session.execute(text('PRAGMA foreign_keys = ON')) entities: Collection[Entity] = ( session.query(Entity).filter(Entity.id.in_(entities)).all()