@@ -1406,45 +1406,8 @@ register(TraversalQueryNode, (node, context) => {
14061406 // if we have both, it might be beneficial to do the field traversal within the mapping node
14071407 // because it may allow ArangoDB to figure out that only one particular field is of interest, and e.g.
14081408 // discard the root entities earlier
1409-
1410- if ( node . captureRootEntity ) {
1411- if ( fieldDepth === 0 ) {
1412- // fieldSegments.length && fieldDepth === 0 means we only traverse through entity extensions
1413- // actually, shouldn't really occur because a collect path can't end with an entity extension and
1414- // value objects don't capture root entities
1415- // however, we can easily implement this so let's do it
1416- mapFrag = ( nodeFrag ) =>
1417- aql `{ obj: ${ getFieldTraversalFragmentWithoutFlattening (
1418- node . fieldSegments ,
1419- nodeFrag ,
1420- ) } , root: ${ nodeFrag } ) }`;
1421- } else {
1422- // the result of getFieldTraversalFragmentWithoutFlattening() now is a list, so we need to iterate
1423- // over it. if the depth is > 1, we need to flatten the deeper ones so we can do one FOR loop over them
1424- // we still return a list, so we just reduce the depth to 1 and not to 0
1425- const entityVar = aql . variable ( 'entity' ) ;
1426- mapFrag = ( rootEntityFrag ) =>
1427- aqlExt . parenthesizeList (
1428- aql `FOR ${ entityVar } IN ${ getFlattenFrag (
1429- getFieldTraversalFragmentWithoutFlattening (
1430- node . fieldSegments ,
1431- rootEntityFrag ,
1432- ) ,
1433- fieldDepth - 1 ,
1434- ) } `,
1435- aql `RETURN { obj: ${ entityVar } , root: ${ rootEntityFrag } }` ,
1436- ) ;
1437- remainingDepth = 1 ;
1438- }
1439- } else {
1440- mapFrag = ( nodeFrag ) =>
1441- getFieldTraversalFragmentWithoutFlattening ( node . fieldSegments , nodeFrag ) ;
1442- }
1443- } else {
1444- if ( node . captureRootEntity ) {
1445- // doesn't make sense to capture the root entity if we're returning the root entities
1446- throw new Error ( `captureRootEntity without fieldSegments detected` ) ;
1447- }
1409+ mapFrag = ( nodeFrag ) =>
1410+ getFieldTraversalFragmentWithoutFlattening ( node . fieldSegments , nodeFrag ) ;
14481411 }
14491412
14501413 // traversal requires real ids
@@ -1480,11 +1443,6 @@ register(TraversalQueryNode, (node, context) => {
14801443 return getFlattenFrag ( frag , remainingDepth - 1 ) ;
14811444 }
14821445
1483- if ( node . captureRootEntity ) {
1484- // doesn't make sense (and isn't possible) to capture the root entity if we're not even crossing root entities
1485- throw new Error ( `captureRootEntity without relationSegments detected` ) ;
1486- }
1487-
14881446 if ( node . sourceIsList ) {
14891447 // don't need, don't bother
14901448 throw new Error ( `sourceIsList without relationSegments detected` ) ;
0 commit comments