Skip to content

Commit

Permalink
fix: sqlalchemy.exc.ArgumentError:
Browse files Browse the repository at this point in the history
* Strings are not accepted for attribute names in loader options; please
  use class-bound attributes directly.

* sqlalchemy >= 2.0
  • Loading branch information
utnapischtim committed Dec 5, 2024
1 parent 6c5d03d commit b43d49b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions invenio_oauthclient/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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=""):
Expand All @@ -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,
Expand Down

0 comments on commit b43d49b

Please sign in to comment.