Skip to content

Commit

Permalink
fix: Fixed overlap cycles shifting
Browse files Browse the repository at this point in the history
  • Loading branch information
wwoytenko committed Aug 27, 2024
1 parent cce8981 commit b538b7f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/db/postgres/subset/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,12 @@ func generateInClauseForOverlap(scopeId int, edges []*Edge, overlap [][]*Edge) s
rightTableKeys, leftTableKeys []string
)

for _, c := range overlap {
var shiftedOverlaps [][]*Edge
for _, oc := range overlap {
shiftedOverlaps = append(shiftedOverlaps, shiftUntilVertexWillBeFirst(edges[0], oc))
}

for _, c := range shiftedOverlaps {
overlapTables = append(overlapTables, getCycleQueryName(scopeId, c, ""))
}
for _, k := range edges[0].from.table.PrimaryKey {
Expand Down Expand Up @@ -1068,3 +1073,15 @@ func shiftCycleGroup(g [][]*Edge) [][]*Edge {
}
return g
}

func shiftUntilVertexWillBeFirst(v *Edge, c []*Edge) []*Edge {
//generateInClauseForOverlap
res := slices.Clone(c)
for {
if res[0].from.idx == v.from.idx {
break
}
res = shiftCycle(res)
}
return res
}

0 comments on commit b538b7f

Please sign in to comment.