Skip to content

Commit

Permalink
Merge pull request terrastruct#962 from alixander/fix-id-delta-4
Browse files Browse the repository at this point in the history
delete hoisting children should ignore parent id
  • Loading branch information
alixander authored Mar 3, 2023
2 parents f6550eb + 37ff3fb commit 996a1c6
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 1 deletion.
2 changes: 1 addition & 1 deletion d2oracle/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func renameConflictsToParent(g *d2graph.Graph, key *d2ast.KeyPath) (*d2graph.Gra
hoistedAbsKey.Path = append(hoistedAbsKey.Path, ref.Key.Path[:ref.KeyPathIndex]...)
hoistedAbsKey.Path = append(hoistedAbsKey.Path, absKey.Path[len(absKey.Path)-1])

uniqueKeyStr, _, err := generateUniqueKey(g, strings.Join(d2graph.Key(hoistedAbsKey), "."), nil, newIDs)
uniqueKeyStr, _, err := generateUniqueKey(g, strings.Join(d2graph.Key(hoistedAbsKey), "."), obj, newIDs)
if err != nil {
return nil, err
}
Expand Down
34 changes: 34 additions & 0 deletions d2oracle/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4834,6 +4834,24 @@ Square: {
Text: {
Text 2
}
Text 2
`,
},
{
name: "conflicts_generated_continued",
text: `Text 4
Text: {
Text 2
}
Text 2
`,
key: `Text`,

exp: `Text 4
Text
Text 2
`,
},
Expand Down Expand Up @@ -5399,6 +5417,22 @@ Square: {
"Square.Text": "Text 2",
"Square.Text 4": "Text",
"Square.Text 4.Text 2": "Text.Text 2"
}`,
},
{
name: "delete_generated_id_conflicts_2_continued",

text: `Text 4
Text: {
Text 2
}
Text 2
`,
key: "Text",

exp: `{
"Text.Text 2": "Text"
}`,
},
}
Expand Down
250 changes: 250 additions & 0 deletions testdata/d2oracle/TestDelete/conflicts_generated_continued.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 996a1c6

Please sign in to comment.