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 for a certain failing relationship layout, fixes https://github.com/toluaina/pgsync/issues/397 #398

Merged
merged 4 commits into from
Dec 16, 2022
Merged
Changes from 3 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: 7 additions & 1 deletion pgsync/querybuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,16 @@ def _non_through(self, node: Node) -> None: # noqa: C901
onclause: list = []

foreign_keys: dict = self._get_foreign_keys(node, child)

table: Optional[str] = (
child.relationship.throughs[0].table
if child.relationship.throughs
else None
)
foreign_key_columns: list = self._get_column_foreign_keys(
child._subquery.columns,
foreign_keys,
table=table,
schema=node.schema,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. only thing I would suggest is to use child.schema here because we do allow cross schema queries. So the child could be in a different namespace.

)

for i in range(len(foreign_key_columns)):
Expand Down