1+ from typing import Any , cast
2+
13from sqlmodel import Session , select
2- from sqlalchemy .orm import selectinload
4+ from sqlalchemy .orm import InstrumentedAttribute , selectinload
35
46from utils .core .models import Organization , Role , User , Invitation
57
@@ -21,13 +23,15 @@ def load_org_for_members_partial(
2123 select (Organization )
2224 .where (Organization .id == organization_id )
2325 .options (
24- selectinload (Organization .roles )
25- .selectinload (Role .users )
26- .selectinload (User .account ),
27- selectinload (Organization .roles )
28- .selectinload (Role .users )
29- .selectinload (User .roles ),
30- selectinload (Organization .roles ).selectinload (Role .permissions ),
26+ selectinload (cast (InstrumentedAttribute [Any ], Organization .roles ))
27+ .selectinload (cast (InstrumentedAttribute [Any ], Role .users ))
28+ .selectinload (cast (InstrumentedAttribute [Any ], User .account )),
29+ selectinload (cast (InstrumentedAttribute [Any ], Organization .roles ))
30+ .selectinload (cast (InstrumentedAttribute [Any ], Role .users ))
31+ .selectinload (cast (InstrumentedAttribute [Any ], User .roles )),
32+ selectinload (
33+ cast (InstrumentedAttribute [Any ], Organization .roles )
34+ ).selectinload (cast (InstrumentedAttribute [Any ], Role .permissions )),
3135 )
3236 ).first ()
3337 user_permissions = _user_permissions_for_org (user , organization_id )
@@ -43,8 +47,12 @@ def load_org_for_roles_partial(
4347 select (Organization )
4448 .where (Organization .id == organization_id )
4549 .options (
46- selectinload (Organization .roles ).selectinload (Role .users ),
47- selectinload (Organization .roles ).selectinload (Role .permissions ),
50+ selectinload (
51+ cast (InstrumentedAttribute [Any ], Organization .roles )
52+ ).selectinload (cast (InstrumentedAttribute [Any ], Role .users )),
53+ selectinload (
54+ cast (InstrumentedAttribute [Any ], Organization .roles )
55+ ).selectinload (cast (InstrumentedAttribute [Any ], Role .permissions )),
4856 )
4957 ).first ()
5058 user_permissions = _user_permissions_for_org (user , organization_id )
0 commit comments