Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Belongs to many - Table can't be without an underscore #825

Merged
merged 1 commit into from
Nov 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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