ignore the parent for delete
This commit is contained in:
parent
f6550eb34c
commit
37ff3fb40b
3 changed files with 285 additions and 1 deletions
|
|
@ -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, ref.Key.Path[:ref.KeyPathIndex]...)
|
||||||
hoistedAbsKey.Path = append(hoistedAbsKey.Path, absKey.Path[len(absKey.Path)-1])
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4834,6 +4834,24 @@ Square: {
|
||||||
Text: {
|
Text: {
|
||||||
Text 2
|
Text 2
|
||||||
}
|
}
|
||||||
|
Text 2
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "conflicts_generated_continued",
|
||||||
|
text: `Text 4
|
||||||
|
|
||||||
|
Text: {
|
||||||
|
Text 2
|
||||||
|
}
|
||||||
|
Text 2
|
||||||
|
`,
|
||||||
|
key: `Text`,
|
||||||
|
|
||||||
|
exp: `Text 4
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
Text 2
|
Text 2
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
@ -5399,6 +5417,22 @@ Square: {
|
||||||
"Square.Text": "Text 2",
|
"Square.Text": "Text 2",
|
||||||
"Square.Text 4": "Text",
|
"Square.Text 4": "Text",
|
||||||
"Square.Text 4.Text 2": "Text.Text 2"
|
"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"
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
250
testdata/d2oracle/TestDelete/conflicts_generated_continued.exp.json
generated
vendored
Normal file
250
testdata/d2oracle/TestDelete/conflicts_generated_continued.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,250 @@
|
||||||
|
{
|
||||||
|
"graph": {
|
||||||
|
"name": "",
|
||||||
|
"isFolderOnly": false,
|
||||||
|
"ast": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,0:0:0-5:0:21",
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,0:0:0-0:6:6",
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,0:0:0-0:6:6",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,0:0:0-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "Text 4",
|
||||||
|
"raw_string": "Text 4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,2:0:8-2:4:12",
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,2:0:8-2:4:12",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,2:0:8-2:4:12",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "Text",
|
||||||
|
"raw_string": "Text"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,4:0:14-4:6:20",
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,4:0:14-4:6:20",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,4:0:14-4:6:20",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "Text 2",
|
||||||
|
"raw_string": "Text 2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"id": "",
|
||||||
|
"id_val": "",
|
||||||
|
"label_dimensions": {
|
||||||
|
"width": 0,
|
||||||
|
"height": 0
|
||||||
|
},
|
||||||
|
"attributes": {
|
||||||
|
"label": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"style": {},
|
||||||
|
"near_key": null,
|
||||||
|
"shape": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"direction": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"constraint": {
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zIndex": 0
|
||||||
|
},
|
||||||
|
"edges": null,
|
||||||
|
"objects": [
|
||||||
|
{
|
||||||
|
"id": "Text 4",
|
||||||
|
"id_val": "Text 4",
|
||||||
|
"label_dimensions": {
|
||||||
|
"width": 0,
|
||||||
|
"height": 0
|
||||||
|
},
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,0:0:0-0:6:6",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,0:0:0-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "Text 4",
|
||||||
|
"raw_string": "Text 4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path_index": 0,
|
||||||
|
"map_key_edge_index": -1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attributes": {
|
||||||
|
"label": {
|
||||||
|
"value": "Text 4"
|
||||||
|
},
|
||||||
|
"style": {},
|
||||||
|
"near_key": null,
|
||||||
|
"shape": {
|
||||||
|
"value": "rectangle"
|
||||||
|
},
|
||||||
|
"direction": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"constraint": {
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zIndex": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Text",
|
||||||
|
"id_val": "Text",
|
||||||
|
"label_dimensions": {
|
||||||
|
"width": 0,
|
||||||
|
"height": 0
|
||||||
|
},
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,2:0:8-2:4:12",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,2:0:8-2:4:12",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "Text",
|
||||||
|
"raw_string": "Text"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path_index": 0,
|
||||||
|
"map_key_edge_index": -1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attributes": {
|
||||||
|
"label": {
|
||||||
|
"value": "Text"
|
||||||
|
},
|
||||||
|
"style": {},
|
||||||
|
"near_key": null,
|
||||||
|
"shape": {
|
||||||
|
"value": "rectangle"
|
||||||
|
},
|
||||||
|
"direction": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"constraint": {
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zIndex": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Text 2",
|
||||||
|
"id_val": "Text 2",
|
||||||
|
"label_dimensions": {
|
||||||
|
"width": 0,
|
||||||
|
"height": 0
|
||||||
|
},
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,4:0:14-4:6:20",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2oracle/TestDelete/conflicts_generated_continued.d2,4:0:14-4:6:20",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "Text 2",
|
||||||
|
"raw_string": "Text 2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path_index": 0,
|
||||||
|
"map_key_edge_index": -1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attributes": {
|
||||||
|
"label": {
|
||||||
|
"value": "Text 2"
|
||||||
|
},
|
||||||
|
"style": {},
|
||||||
|
"near_key": null,
|
||||||
|
"shape": {
|
||||||
|
"value": "rectangle"
|
||||||
|
},
|
||||||
|
"direction": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"constraint": {
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zIndex": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"err": "<nil>"
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue