Skip to content

Commit

Permalink
Merge pull request #825 from maicol07/2.0
Browse files Browse the repository at this point in the history
fix: Belongs to many - Table can't be without an underscore
  • Loading branch information
josephmancuso authored Nov 7, 2022
2 parents c91da8d + 8c87f48 commit 325ec29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/masoniteorm/relationships/BelongsToMany.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def apply_query(self, query, owner):
self._table = "_".join(pivot_tables)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
else:
elif self.local_key is None or self.foreign_key is None:
pivot_table_1, pivot_table_2 = self._table.split("_", 1)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
Expand Down Expand Up @@ -185,7 +185,7 @@ def make_query(self, query, relation, eagers=None, callback=None):
self._table = "_".join(pivot_tables)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
else:
elif self.local_key is None or self.foreign_key is None:
pivot_table_1, pivot_table_2 = self._table.split("_", 1)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
Expand Down Expand Up @@ -302,7 +302,7 @@ def relate(self, related_record):
self._table = "_".join(pivot_tables)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
else:
elif self.local_key is None or self.foreign_key is None:
pivot_table_1, pivot_table_2 = self._table.split("_", 1)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
Expand Down Expand Up @@ -368,7 +368,7 @@ def joins(self, builder, clause=None):
self._table = "_".join(pivot_tables)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
else:
elif self.local_key is None or self.foreign_key is None:
pivot_table_1, pivot_table_2 = self._table.split("_", 1)
self.foreign_key = self.foreign_key or f"{pivot_table_1}_id"
self.local_key = self.local_key or f"{pivot_table_2}_id"
Expand Down

0 comments on commit 325ec29

Please sign in to comment.