d2oracle: glob null edges

This commit is contained in:
Alexander Wang 2024-06-03 13:11:45 -06:00
parent 94d5ab5d2e
commit 15ba701576
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
3 changed files with 491 additions and 1 deletions

View file

@ -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
} }
@ -1016,6 +1016,11 @@ func (c *compiler) _compileEdges(refctx *RefContext) {
}) })
refctx.ScopeMap.appendFieldReferences(0, refctx.Edge.Src, refctx, c) refctx.ScopeMap.appendFieldReferences(0, refctx.Edge.Src, refctx, c)
refctx.ScopeMap.appendFieldReferences(0, refctx.Edge.Dst, refctx, c) refctx.ScopeMap.appendFieldReferences(0, refctx.Edge.Dst, refctx, c)
if refctx.Key.Primary.Null != nil || refctx.Key.Value.Null != nil {
refctx.ScopeMap.DeleteEdge(e.ID)
continue
}
} }
} else { } else {
var err error var err error

View file

@ -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) {

View 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": []
}