Wrap the `PRAGMA` statement in `sqlalchemy.text`.

SQLAlchemy 2 no longer supports raw strings passed to `.execute()`
methods.
This commit is contained in:
Fabio Manganiello 2023-04-25 10:41:37 +02:00
parent 440d70d9cf
commit dd60b8924d
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 2 additions and 2 deletions

View File

@ -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()