From b43d49bb9da6ef037fe592d22fff2f32c79d83c7 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Thu, 5 Dec 2024 23:17:39 +0100 Subject: [PATCH] fix: sqlalchemy.exc.ArgumentError: * Strings are not accepted for attribute names in loader options; please use class-bound attributes directly. * sqlalchemy >= 2.0 --- invenio_oauthclient/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/invenio_oauthclient/models.py b/invenio_oauthclient/models.py index 56039c1f..4386527b 100644 --- a/invenio_oauthclient/models.py +++ b/invenio_oauthclient/models.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2018 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. @@ -174,7 +175,11 @@ def get(cls, user_id, client_id, token_type="", access_token=None): if access_token: args.append(RemoteToken.access_token == access_token) - return cls.query.options(db.joinedload("remote_account")).filter(*args).first() + return ( + cls.query.options(db.joinedload(RemoteToken.remote_account)) + .filter(*args) + .first() + ) @classmethod def get_by_token(cls, client_id, access_token, token_type=""): @@ -186,7 +191,7 @@ def get_by_token(cls, client_id, access_token, token_type=""): :returns: A :class:`invenio_oauthclient.models.RemoteToken` instance. """ return ( - cls.query.options(db.joinedload("remote_account")) + cls.query.options(db.joinedload(RemoteToken.remote_account)) .filter( RemoteAccount.id == RemoteToken.id_remote_account, RemoteAccount.client_id == client_id,