d2ir: fix merging boards with array composites
This commit is contained in:
parent
00f5eefe0b
commit
6a4c7a51f8
4 changed files with 418 additions and 1 deletions
|
|
@ -3,3 +3,5 @@
|
|||
#### Improvements 🧹
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
||||
- Fix importing files that override an existing value with an array. [#1762](https://github.com/terrastruct/d2/pull/1762)
|
||||
|
|
|
|||
|
|
@ -199,6 +199,18 @@ label: meow`,
|
|||
assert.Success(t, err)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "merge-arrays",
|
||||
run: func(t testing.TB) {
|
||||
_, err := compileFS(t, "index.d2", map[string]string{
|
||||
"index.d2": `x.class: [a]
|
||||
...@d
|
||||
`,
|
||||
"d.d2": `x.class: [b]`,
|
||||
})
|
||||
assert.Success(t, err)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
runa(t, tca)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func OverlayField(bf, of *Field) {
|
|||
if bf.Map() != nil && of.Map() != nil {
|
||||
OverlayMap(bf.Map(), of.Map())
|
||||
} else {
|
||||
bf.Composite = of.Composite.Copy(bf).(*Map)
|
||||
bf.Composite = of.Composite.Copy(bf).(Composite)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
403
testdata/d2ir/TestCompile/imports/merge-arrays.exp.json
generated
vendored
Normal file
403
testdata/d2ir/TestCompile/imports/merge-arrays.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,403 @@
|
|||
{
|
||||
"fields": [
|
||||
{
|
||||
"name": "x",
|
||||
"composite": {
|
||||
"fields": [
|
||||
{
|
||||
"name": "class",
|
||||
"composite": {
|
||||
"values": [
|
||||
{
|
||||
"value": {
|
||||
"range": "d.d2,0:10:10-0:11:11",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"string": {
|
||||
"range": "index.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path": {
|
||||
"range": "index.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"context": {
|
||||
"edge": null,
|
||||
"key": {
|
||||
"range": "index.d2,0:0:0-0:12:12",
|
||||
"key": {
|
||||
"range": "index.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"array": {
|
||||
"range": "index.d2,0:9:9-1:0:13",
|
||||
"nodes": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:10:10-0:11:11",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"due_to_glob": false,
|
||||
"due_to_lazy_glob": false
|
||||
},
|
||||
{
|
||||
"string": {
|
||||
"range": "d.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path": {
|
||||
"range": "d.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"context": {
|
||||
"edge": null,
|
||||
"key": {
|
||||
"range": "d.d2,0:0:0-0:12:12",
|
||||
"key": {
|
||||
"range": "d.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"array": {
|
||||
"range": "d.d2,0:9:9-0:12:12",
|
||||
"nodes": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:10:10-0:11:11",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"due_to_glob": false,
|
||||
"due_to_lazy_glob": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"edges": null
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"string": {
|
||||
"range": "index.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path": {
|
||||
"range": "index.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"context": {
|
||||
"edge": null,
|
||||
"key": {
|
||||
"range": "index.d2,0:0:0-0:12:12",
|
||||
"key": {
|
||||
"range": "index.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"array": {
|
||||
"range": "index.d2,0:9:9-1:0:13",
|
||||
"nodes": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:10:10-0:11:11",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"due_to_glob": false,
|
||||
"due_to_lazy_glob": false
|
||||
},
|
||||
{
|
||||
"string": {
|
||||
"range": "d.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path": {
|
||||
"range": "d.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"context": {
|
||||
"edge": null,
|
||||
"key": {
|
||||
"range": "d.d2,0:0:0-0:12:12",
|
||||
"key": {
|
||||
"range": "d.d2,0:0:0-0:7:7",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:2:2-0:7:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "class",
|
||||
"raw_string": "class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"array": {
|
||||
"range": "d.d2,0:9:9-0:12:12",
|
||||
"nodes": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d.d2,0:10:10-0:11:11",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"due_to_glob": false,
|
||||
"due_to_lazy_glob": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"edges": null
|
||||
}
|
||||
Loading…
Reference in a new issue