Skip to content

Commit

Permalink
fix some mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Ckk3 committed Nov 23, 2024
1 parent 0182a82 commit fe8bf1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/strawberry_sqlalchemy_mapper/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ async def load_fn(keys: List[Tuple]) -> List[Any]:
# Use another query when relationship uses a secondary table
self_model = relationship.parent.entity

self_model_key_label = relationship.local_remote_pairs[0][1].key
related_model_key_label = relationship.local_remote_pairs[1][1].key
self_model_key_label = str(relationship.local_remote_pairs[0][1].key)
related_model_key_label = str(relationship.local_remote_pairs[1][1].key)

self_model_key = relationship.local_remote_pairs[0][0].key
related_model_key = relationship.local_remote_pairs[1][0].key
self_model_key = str(relationship.local_remote_pairs[0][0].key)
related_model_key = str(relationship.local_remote_pairs[1][0].key)

remote_to_use = relationship.local_remote_pairs[0][1]
query_keys = tuple([item[0] for item in keys])
Expand Down
20 changes: 12 additions & 8 deletions src/strawberry_sqlalchemy_mapper/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,18 @@ async def resolve(self, info: Info):
)
else:
# If has a secondary table, gets only the first ID as additional IDs require a separate query
local_remote_pairs_secondary_table_local = relationship.local_remote_pairs[
0][0]
relationship_key = tuple(
[
getattr(
self, str(local_remote_pairs_secondary_table_local.key)),
]
)
relationship_key = ()
if relationship.local_remote_pairs:
local_remote_pairs_secondary_table_local = relationship.local_remote_pairs[0][0]
relationship_key = tuple(
[
getattr(
self, str(local_remote_pairs_secondary_table_local.key)),
]
)
return relationship_key



if any(item is None for item in relationship_key):
if relationship.uselist:
Expand Down

0 comments on commit fe8bf1f

Please sign in to comment.