From fea9a7e4a56e2bf3e57f9cad7fc36b2f36eb6435 Mon Sep 17 00:00:00 2001 From: MeRuslan Date: Sat, 17 Dec 2022 01:08:26 +0300 Subject: [PATCH] Fix for a certain failing relationship layout, fixes https://github.com/toluaina/pgsync/issues/397 (#398) * Update querybuilder.py * Update querybuilder.py make flake happy? * use child chema when building child's children with through --- pgsync/querybuilder.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pgsync/querybuilder.py b/pgsync/querybuilder.py index f90a8f53..aaa42942 100644 --- a/pgsync/querybuilder.py +++ b/pgsync/querybuilder.py @@ -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=child.schema, ) for i in range(len(foreign_key_columns)):