delete id deltas reserved

This commit is contained in:
Alexander Wang 2023-02-20 09:39:32 -08:00
parent 95eccae9c1
commit b1a1b2300c
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
2 changed files with 17 additions and 0 deletions

View file

@ -1864,6 +1864,12 @@ func DeleteIDDeltas(g *d2graph.Graph, key string) (deltas map[string]string, err
conflictNewIDs := make(map[*d2graph.Object]string) conflictNewIDs := make(map[*d2graph.Object]string)
conflictOldIDs := make(map[*d2graph.Object]string) conflictOldIDs := make(map[*d2graph.Object]string)
if mk.Key != nil { if mk.Key != nil {
ida := d2graph.Key(mk.Key)
// Deleting a reserved field cannot possibly have any deltas
if _, ok := d2graph.ReservedKeywords[ida[len(ida)-1]]; ok {
return nil, nil
}
var ok bool var ok bool
obj, ok = g.Root.HasChild(d2graph.Key(mk.Key)) obj, ok = g.Root.HasChild(d2graph.Key(mk.Key))
if !ok { if !ok {

View file

@ -4895,7 +4895,18 @@ x.y.z.w.e.p.l -> x.y.z.1.2.3.4
"x.x": "x" "x.x": "x"
}`, }`,
}, },
{
name: "nested-height",
text: `x: {
a -> b
height: 200
}
`,
key: `x.height`,
exp: `null`,
},
{ {
name: "only-reserved", name: "only-reserved",
text: `guitar: { text: `guitar: {