Skip to content

Commit

Permalink
Fix link properties on back links not finding output.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed Jul 5, 2024
1 parent e5276ac commit 3125520
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions edb/pgsql/compiler/relctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2257,6 +2257,10 @@ def _range_for_component_ptrref(
rarg=rarg,
)

# Add the path to the CTE's query. This allows for the proper
# path mapping ot occur when processing link properties
inheritance_qry.path_id = component_ptrref_path_id

ptr_cte = pgast.CommonTableExpr(
name=ctx.env.aliases.get(f't_{component_ptrref.name}'),
query=inheritance_qry,
Expand Down
15 changes: 15 additions & 0 deletions edb/pgsql/compiler/relgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,21 @@ def process_set_as_link_property_ref(
),
),
)
elif isinstance(link_rvar.query, pgast.SelectStmt):
# When processing link properties into a CTE, map the current link
# path id into the form used by the CTE.

for from_rvar in link_rvar.query.from_clause:
if (
isinstance(from_rvar, pgast.RelRangeVar)
and isinstance(from_rvar.relation, pgast.CommonTableExpr)
and from_rvar.relation.query.path_id is not None
):
pathctx.put_path_id_map(
link_rvar.query,
link_path_id,
from_rvar.relation.query.path_id
)

rvars.append(SetRVar(
link_rvar,
Expand Down

0 comments on commit 3125520

Please sign in to comment.