Skip to content

Commit 2509106

Browse files
committed
Fix linking isolated subqueries within iterate()
1 parent e3cee4a commit 2509106

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/link.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ struct LinkContext
1414
Base.ImmutableDict{Tuple{Symbol, Int}, Vector{SQLNode}}(),
1515
nothing)
1616

17-
LinkContext(ctx::LinkContext; defs = missing, refs = missing, cte_refs = missing, knot_refs = missing) =
17+
LinkContext(ctx::LinkContext; refs = missing, cte_refs = missing, knot_refs = missing) =
1818
new(ctx.dialect,
19-
coalesce(defs, ctx.defs),
19+
ctx.defs,
2020
coalesce(refs, ctx.refs),
2121
coalesce(cte_refs, ctx.cte_refs),
2222
coalesce(knot_refs, ctx.knot_refs))
@@ -335,12 +335,13 @@ function link(n::IterateNode, ctx)
335335
for (v, l) in cte_refs
336336
resize!(v, l)
337337
end
338-
iterator′ = link(n.iterator, LinkContext(ctx, defs = defs, refs = refs, knot_refs = knot_refs))
338+
iterator′ = link(n.iterator, LinkContext(ctx, refs = refs, knot_refs = knot_refs))
339339
repeat = false
340340
seen = Set(refs)
341341
for ref in knot_refs
342342
if !in(ref, seen)
343343
repeat = true
344+
ctx.defs .= defs
344345
break
345346
end
346347
end

0 commit comments

Comments
 (0)