fix move id delta
This commit is contained in:
parent
282167781c
commit
1cef4177fb
3 changed files with 37 additions and 2 deletions
|
|
@ -1886,7 +1886,7 @@ func MoveIDDeltas(g *d2graph.Graph, key, newKey string) (deltas map[string]strin
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := g.Root.HasChild(d2graph.Key(hoistedMK.Key)); ok || conflictsWithNewID {
|
if _, ok := g.Root.HasChild(d2graph.Key(hoistedMK.Key)); ok || conflictsWithNewID {
|
||||||
newKey, _, err := generateUniqueKey(g, hoistedAbsID, nil, newIDs)
|
newKey, _, err := generateUniqueKey(g, hoistedAbsID, obj, newIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3372,6 +3372,24 @@ b: {
|
||||||
exp: `b: {
|
exp: `b: {
|
||||||
a
|
a
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "container_conflicts_generated",
|
||||||
|
text: `Square 2: "" {
|
||||||
|
Square: ""
|
||||||
|
}
|
||||||
|
Square: ""
|
||||||
|
Square 3
|
||||||
|
`,
|
||||||
|
key: `Square 2`,
|
||||||
|
newKey: `Square 3.Square 2`,
|
||||||
|
|
||||||
|
exp: `Square 4: ""
|
||||||
|
Square: ""
|
||||||
|
Square 3: {
|
||||||
|
Square 2: ""
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -4939,6 +4957,7 @@ Text
|
||||||
Text 2
|
Text 2
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "drop_value",
|
name: "drop_value",
|
||||||
text: `a.b.c: "c label"
|
text: `a.b.c: "c label"
|
||||||
|
|
@ -5278,6 +5297,22 @@ x.a -> x.b
|
||||||
"x.(a -> b)[0]": "(a 2 -> b)[0]",
|
"x.(a -> b)[0]": "(a 2 -> b)[0]",
|
||||||
"x.a": "a 2",
|
"x.a": "a 2",
|
||||||
"x.b": "b"
|
"x.b": "b"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "container_conflicts_generated",
|
||||||
|
text: `Square 2: "" {
|
||||||
|
Square: ""
|
||||||
|
}
|
||||||
|
Square: ""
|
||||||
|
Square 3
|
||||||
|
`,
|
||||||
|
key: `Square 2`,
|
||||||
|
newKey: `Square 3.Square 2`,
|
||||||
|
|
||||||
|
exp: `{
|
||||||
|
"Square 2": "Square 3.Square 2",
|
||||||
|
"Square 2.Square": "Square 2"
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ func GetParentID(g *d2graph.Graph, absID string) (string, error) {
|
||||||
}
|
}
|
||||||
obj, ok := g.Root.HasChild(d2graph.Key(mk.Key))
|
obj, ok := g.Root.HasChild(d2graph.Key(mk.Key))
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("%v parent not found", absID)
|
return "", fmt.Errorf("%v not found", absID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj.Parent.AbsID(), nil
|
return obj.Parent.AbsID(), nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue