commit
c0d565bd93
5 changed files with 115 additions and 2 deletions
|
|
@ -31,3 +31,4 @@ Hope everyone is enjoying the holidays this week!
|
|||
- Connections at the boundaries no longer get part of its stroke clipped. [#493](https://github.com/terrastruct/d2/pull/493)
|
||||
- Fixes edge case where `style` being defined in same scope as `sql_table` causes compiler to skip compiling `sql_table`. [#506](https://github.com/terrastruct/d2/issues/506)
|
||||
- Fixes panic passing a non-string value to `constraint`. [#248](https://github.com/terrastruct/d2/issues/248)
|
||||
- Fixes edge case where the key `null` was compiling wrongly. [#507](https://github.com/terrastruct/d2/issues/507)
|
||||
|
|
|
|||
|
|
@ -1672,6 +1672,16 @@ choo: {
|
|||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "null",
|
||||
|
||||
text: `null
|
||||
`,
|
||||
assertions: func(t *testing.T, g *d2graph.Graph) {
|
||||
tassert.Equal(t, "'null'", g.Objects[0].ID)
|
||||
tassert.Equal(t, "null", g.Objects[0].IDVal)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sql-regression",
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func escapeUnquotedValue(s string, inKey bool) string {
|
|||
}
|
||||
|
||||
if strings.EqualFold(s, "null") {
|
||||
return "\\null"
|
||||
return `'null'`
|
||||
}
|
||||
|
||||
var b strings.Builder
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ func TestEscapeUnquoted(t *testing.T) {
|
|||
{
|
||||
name: "null",
|
||||
str: `null`,
|
||||
exp: `\null`,
|
||||
exp: `'null'`,
|
||||
},
|
||||
{
|
||||
name: "empty",
|
||||
|
|
|
|||
102
testdata/d2compiler/TestCompile/null.exp.json
generated
vendored
Normal file
102
testdata/d2compiler/TestCompile/null.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
{
|
||||
"graph": {
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/null.d2,0:0:0-1:0:5",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/null.d2,0:0:0-0:4:4",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/null.d2,0:0:0-0:4:4",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/null.d2,0:0:0-0:4:4",
|
||||
"value": [
|
||||
{
|
||||
"string": "null",
|
||||
"raw_string": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"root": {
|
||||
"id": "",
|
||||
"id_val": "",
|
||||
"label_dimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": ""
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
"edges": null,
|
||||
"objects": [
|
||||
{
|
||||
"id": "'null'",
|
||||
"id_val": "null",
|
||||
"label_dimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/null.d2,0:0:0-0:4:4",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/null.d2,0:0:0-0:4:4",
|
||||
"value": [
|
||||
{
|
||||
"string": "null",
|
||||
"raw_string": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "null"
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": null
|
||||
}
|
||||
Loading…
Reference in a new issue