From 5dafc4218a533afdea29510f9702d2692362b59c Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Fri, 4 Oct 2024 22:00:20 +0200 Subject: [PATCH] model: make forward compatible to sqlalchemy >= 2 --- invenio_records/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/invenio_records/api.py b/invenio_records/api.py index 6d0d707b..0fce2bb0 100644 --- a/invenio_records/api.py +++ b/invenio_records/api.py @@ -3,6 +3,7 @@ # This file is part of Invenio. # Copyright (C) 2015-2020 CERN. # Copyright (C) 2021 RERO. +# Copyright (C) 2024 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -377,7 +378,7 @@ def get_record(cls, id_, with_deleted=False): :returns: The :class:`Record` instance. """ with db.session.no_autoflush: - query = cls.model_cls.query.filter_by(id=id_) + query = db.session.query(cls.model_cls).filter_by(id=id_) if not with_deleted: query = query.filter(cls.model_cls.is_deleted != True) # noqa obj = query.one() @@ -392,7 +393,7 @@ def get_records(cls, ids, with_deleted=False): :returns: A list of :class:`Record` instances. """ with db.session.no_autoflush: - query = cls.model_cls.query.filter(cls.model_cls.id.in_(ids)) + query = db.session.query(cls.model_cls).filter(cls.model_cls.id.in_(ids)) if not with_deleted: query = query.filter(cls.model_cls.is_deleted != True) # noqa