From 3bd1228e9740b2e337cba03e8d428b7aac7698de Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Tue, 5 Nov 2024 10:00:53 +0100 Subject: [PATCH] fix: LegacyAPIWarning of sqlalchemy * LegacyAPIWarning: The Query.get() method is considered legacy as of the 1.x series of SQLAlchemy and becomes a legacy construct in 2.0. The method is now available as Session.get() (deprecated since: 2.0) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9) role = current_datastore.role_model.query.get(id_) --- invenio_files_rest/tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/invenio_files_rest/tasks.py b/invenio_files_rest/tasks.py index 67779a72..c8fc34e7 100644 --- a/invenio_files_rest/tasks.py +++ b/invenio_files_rest/tasks.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2019 CERN. +# 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. @@ -43,7 +44,7 @@ def verify_checksum( :param file_id: The file ID. """ - f = FileInstance.query.get(uuid.UUID(file_id)) + f = db.session.get(FileInstance, uuid.UUID(file_id)) # Anything might happen during the task, so being pessimistic and marking # the file as unchecked is a reasonable precaution