Skip to content

Commit

Permalink
fixed querybuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Sep 1, 2024
1 parent 25a965a commit 8c9a6bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/masoniteorm/query/QueryBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,11 +1955,11 @@ def _register_relationships_to_model(
map_related = self._map_related(related_result, related)
for model in hydrated_model:
if isinstance(related_result, Collection):
related.register_related(relation_key, model, related_result)
related.register_related(relation_key, model, map_related)
else:
model.add_relation({relation_key: related_result or None})
model.add_relation({relation_key: map_related or None})
else:
hydrated_model.add_relation({relation_key: related_result or None})
hydrated_model.add_relation({relation_key: map_related or None})
return self

def _map_related(self, related_result, related):
Expand Down
2 changes: 1 addition & 1 deletion src/masoniteorm/relationships/HasMany.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ def set_keys(self, owner, attribute):

def register_related(self, key, model, collection):
model.add_relation(
{key: collection.where(self.foreign_key, getattr(model, self.local_key)) or Collection()}
{key: collection.get(getattr(model, self.local_key)) or Collection()}
)

0 comments on commit 8c9a6bb

Please sign in to comment.