@@ -17,6 +17,7 @@ type normalizeQueryContext struct {
1717 colIndexMap map [string ]int
1818 headObjDepthOffset int
1919 maxDepth int
20+ viewGraph map [int ]SoqlGraphLeaf
2021}
2122
2223func (ctx * normalizeQueryContext ) normalizeQuery (
@@ -257,12 +258,18 @@ func (ctx *normalizeQueryContext) normalizeQuery(
257258 if ctx .maxDepth < objDepth {
258259 ctx .maxDepth = objDepth
259260 }
261+
260262 if nameLen > 1 {
261263 parentKey := nameutil .MakeDottedKeyIgnoreCase (q .From [i ].Name , nameLen - 1 )
262264 if parentViewId , ok := ctx .viewIdMap [parentKey ]; ok {
263265 q .From [i ].ParentViewId = parentViewId
264266 }
265267 }
268+
269+ ctx .viewGraph [q .From [i ].ViewId ] = SoqlGraphLeaf {
270+ ParentViewId : q .From [i ].ParentViewId ,
271+ Object : & q .From [i ],
272+ }
266273 }
267274
268275 // TODO: * check object graph when aggregation(group by)
@@ -390,6 +397,7 @@ func Normalize(q *SoqlQuery) error {
390397 colIndexMap : map [string ]int {},
391398 headObjDepthOffset : 0 ,
392399 maxDepth : 0 ,
400+ viewGraph : make (map [int ]SoqlGraphLeaf ),
393401 }
394402
395403 if err := ctx .normalizeQuery (soqlQueryPlace_Primary , q , nil ); err != nil {
@@ -399,6 +407,7 @@ func Normalize(q *SoqlQuery) error {
399407 q .Meta .NextColumnId = ctx .columnId
400408 q .Meta .NextViewId = ctx .viewId
401409 q .Meta .MaxDepth = ctx .maxDepth
410+ q .Meta .ViewGraph = ctx .viewGraph
402411
403412 return nil
404413}
0 commit comments