From e12a317e7a1f7958e74db27b46d8a35cffa35ab8 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 27 Jun 2023 13:54:50 +0200 Subject: [PATCH] join some more relationships --- jupyterhub/orm.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jupyterhub/orm.py b/jupyterhub/orm.py index 57eb732f..ae59989b 100644 --- a/jupyterhub/orm.py +++ b/jupyterhub/orm.py @@ -818,14 +818,14 @@ class OAuthCode(Expiring, Base): client_id = Column( Unicode(255), ForeignKey('oauth_clients.identifier', ondelete='CASCADE') ) - client = relationship("OAuthClient", back_populates="codes") + client = relationship("OAuthClient", back_populates="codes", lazy="joined") code = Column(Unicode(36)) expires_at = Column(Integer) redirect_uri = Column(Unicode(1023)) session_id = Column(Unicode(255)) # state = Column(Unicode(1023)) user_id = Column(Integer, ForeignKey('users.id', ondelete='CASCADE')) - user = relationship("User", back_populates="oauth_codes") + user = relationship("User", back_populates="oauth_codes", lazy="joined") scopes = Column(JSONList, default=[]) @@ -860,8 +860,12 @@ class OAuthClient(Base): def client_id(self): return self.identifier - spawner = relationship("Spawner", back_populates="oauth_client", uselist=False) - service = relationship("Service", back_populates="oauth_client", uselist=False) + spawner = relationship( + "Spawner", back_populates="oauth_client", uselist=False, lazy="joined" + ) + service = relationship( + "Service", back_populates="oauth_client", uselist=False, lazy="joined" + ) access_tokens = relationship( APIToken, back_populates='oauth_client', cascade='all, delete-orphan' )