Skip to content

Commit

Permalink
Refactor ReferenceName to just Reference
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Jan 3, 2025
1 parent ca5a186 commit 3046740
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion modules/aql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func parseNodeFilter(ts *TokenStream, ao *engine.Objects) (NodeQuery, error) {
var result NodeQuery

if ts.Token().Type == Identifier && (ts.PeekNextToken().Type == Colon || ts.PeekNextToken().Type == Is) {
result.ReferenceName = ts.Token().Value
result.Reference = ts.Token().Value
ts.Next()
ts.Next()
}
Expand Down
24 changes: 12 additions & 12 deletions modules/aql/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ type IndexLookup struct {
}

type NodeQuery struct {
IndexLookup IndexLookup // Possible start of search, quickly narrows it down
Selector query.NodeFilter // Where style boolean approval filter for objects
OrderBy NodeSorter // Sorting
ReferenceName string // For cross result reference
Skip int // Skipping
Limit int // Limiting
IndexLookup IndexLookup // Possible start of search, quickly narrows it down
Selector query.NodeFilter // Where style boolean approval filter for objects
OrderBy NodeSorter // Sorting
Reference string // For cross result reference
Skip int // Skipping
Limit int // Limiting
}

func (nq NodeQuery) Populate(ao *engine.Objects) *engine.Objects {
Expand Down Expand Up @@ -163,8 +163,8 @@ func (aqlq AQLquery) Resolve(opts ResolverOptions) (*graph.Graph[*engine.Object,
if len(aqlq.Sources) == 1 {
aqlq.sourceCache[0].Iterate(func(o *engine.Object) bool {
result.AddNode(o)
if aqlq.Sources[0].ReferenceName != "" {
result.SetNodeData(o, "reference", aqlq.Sources[0].ReferenceName)
if aqlq.Sources[0].Reference != "" {
result.SetNodeData(o, "reference", aqlq.Sources[0].Reference)
}
return true
})
Expand Down Expand Up @@ -308,15 +308,15 @@ func (aqlq AQLquery) resolveEdgesFrom(
} else {
workingGraph.AddEdge(nextObject, currentObject, addedge)
}
if !hadCurrentNode && aqlq.Sources[currentSearchIndex].ReferenceName != "" {
workingGraph.SetNodeData(currentObject, "reference", aqlq.Sources[currentSearchIndex].ReferenceName)
if !hadCurrentNode && aqlq.Sources[currentSearchIndex].Reference != "" {
workingGraph.SetNodeData(currentObject, "reference", aqlq.Sources[currentSearchIndex].Reference)
}
if targets.Contains(nextObject) {
// We could be done already, if the targetObject matches
if currentSearchIndex == len(aqlq.Next)-1 {
// wowzers, we're done - add this to the committed graph and return
if !hadNextNode && aqlq.Sources[currentSearchIndex+1].ReferenceName != "" {
workingGraph.SetNodeData(nextObject, "reference", aqlq.Sources[currentSearchIndex+1].ReferenceName)
if !hadNextNode && aqlq.Sources[currentSearchIndex+1].Reference != "" {
workingGraph.SetNodeData(nextObject, "reference", aqlq.Sources[currentSearchIndex+1].Reference)
}
committedGraph.Merge(*workingGraph)
} else {
Expand Down

0 comments on commit 3046740

Please sign in to comment.