Skip to content

Commit

Permalink
model: make forward compatible to sqlalchemy >= 2
Browse files Browse the repository at this point in the history
  • Loading branch information
utnapischtim committed Nov 5, 2024
1 parent 3574203 commit 66e542e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions invenio_records/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand All @@ -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

Expand Down

0 comments on commit 66e542e

Please sign in to comment.