Merge pull request #1965 from alixander/scenario-glob
d2oracle: glob null edges
This commit is contained in:
commit
f15f0e9ab9
4 changed files with 491 additions and 2 deletions
|
|
@ -269,7 +269,7 @@ func (gs *dslGenState) randStr(n int, inKey bool) string {
|
||||||
func (gs *dslGenState) randShape() string {
|
func (gs *dslGenState) randShape() string {
|
||||||
for {
|
for {
|
||||||
s := shapes[gs.rand.Intn(len(shapes))]
|
s := shapes[gs.rand.Intn(len(shapes))]
|
||||||
if s != d2target.ShapeImage {
|
if s != d2target.ShapeImage && s != d2target.ShapeText {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -991,7 +991,7 @@ func (c *compiler) compileEdges(refctx *RefContext) {
|
||||||
func (c *compiler) _compileEdges(refctx *RefContext) {
|
func (c *compiler) _compileEdges(refctx *RefContext) {
|
||||||
eida := NewEdgeIDs(refctx.Key)
|
eida := NewEdgeIDs(refctx.Key)
|
||||||
for i, eid := range eida {
|
for i, eid := range eida {
|
||||||
if refctx.Key != nil && refctx.Key.Value.Null != nil {
|
if !eid.Glob && (refctx.Key.Primary.Null != nil || refctx.Key.Value.Null != nil) {
|
||||||
refctx.ScopeMap.DeleteEdge(eid)
|
refctx.ScopeMap.DeleteEdge(eid)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -1009,6 +1009,10 @@ func (c *compiler) _compileEdges(refctx *RefContext) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, e := range ea {
|
for _, e := range ea {
|
||||||
|
if refctx.Key.Primary.Null != nil || refctx.Key.Value.Null != nil {
|
||||||
|
refctx.ScopeMap.DeleteEdge(e.ID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
e.References = append(e.References, &EdgeReference{
|
e.References = append(e.References, &EdgeReference{
|
||||||
Context_: refctx,
|
Context_: refctx,
|
||||||
DueToGlob_: len(c.globRefContextStack) > 0,
|
DueToGlob_: len(c.globRefContextStack) > 0,
|
||||||
|
|
|
||||||
|
|
@ -310,6 +310,18 @@ layers.x: { wrapper.p }
|
||||||
assertQuery(t, m, 0, 0, nil, "layers.x.wrapper.p")
|
assertQuery(t, m, 0, 0, nil, "layers.x.wrapper.p")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "edge-glob-null",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
m, err := compile(t, `a -> b
|
||||||
|
(* -> *)[*]: null
|
||||||
|
x -> y
|
||||||
|
`)
|
||||||
|
assert.Success(t, err)
|
||||||
|
// 4 fields and 0 edges
|
||||||
|
assertQuery(t, m, 4, 0, nil, "")
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "double-glob/edge/1",
|
name: "double-glob/edge/1",
|
||||||
run: func(t testing.TB) {
|
run: func(t testing.TB) {
|
||||||
|
|
|
||||||
473
testdata/d2ir/TestCompile/patterns/edge-glob-null.exp.json
generated
vendored
Normal file
473
testdata/d2ir/TestCompile/patterns/edge-glob-null.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,473 @@
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "a",
|
||||||
|
"raw_string": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "a",
|
||||||
|
"raw_string": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"edge": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:6:6",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "a",
|
||||||
|
"raw_string": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:6:6",
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:6:6",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "a",
|
||||||
|
"raw_string": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"due_to_glob": false,
|
||||||
|
"due_to_lazy_glob": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"edge": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:6:6",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "a",
|
||||||
|
"raw_string": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:6:6",
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:6:6",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:0:0-0:1:1",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "a",
|
||||||
|
"raw_string": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,0:5:5-0:6:6",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"due_to_glob": false,
|
||||||
|
"due_to_lazy_glob": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x",
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "x",
|
||||||
|
"raw_string": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "x",
|
||||||
|
"raw_string": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"edge": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:6:31",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "x",
|
||||||
|
"raw_string": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "y",
|
||||||
|
"raw_string": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:6:31",
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:6:31",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "x",
|
||||||
|
"raw_string": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "y",
|
||||||
|
"raw_string": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"due_to_glob": false,
|
||||||
|
"due_to_lazy_glob": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "y",
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "y",
|
||||||
|
"raw_string": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "y",
|
||||||
|
"raw_string": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"edge": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:6:31",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "x",
|
||||||
|
"raw_string": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "y",
|
||||||
|
"raw_string": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:6:31",
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:6:31",
|
||||||
|
"src": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:0:25-2:1:26",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "x",
|
||||||
|
"raw_string": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "TestCompile/patterns/edge-glob-null.d2,2:5:30-2:6:31",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "y",
|
||||||
|
"raw_string": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"due_to_glob": false,
|
||||||
|
"due_to_lazy_glob": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"edges": []
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue