MCPcopy Create free account
hub / github.com/codemix/graph / buildReturnAliasMap

Function buildReturnAliasMap

packages/graph/src/astToSteps.ts:3019–3046  ·  view source on GitHub ↗

* Build a map of aliases from RETURN clause items. * Maps alias name → underlying variable/property info.

(returnClause: ReturnClause | undefined)

Source from the content-addressed store, hash-verified

3017 * Maps alias name → underlying variable/property info.
3018 */
3019function buildReturnAliasMap(returnClause: ReturnClause | undefined): Map<string, AliasInfo> {
3020 const aliasMap = new Map<string, AliasInfo>();
3021 if (!returnClause) return aliasMap;
3022
3023 for (const item of returnClause.items) {
3024 if (item.alias) {
3025 // Alias explicitly specified
3026 aliasMap.set(item.alias, {
3027 variable: item.variable ?? "",
3028 property: item.property,
3029 });
3030 } else if (item.variable && !item.property) {
3031 // Plain variable reference like RETURN n (alias is implicitly 'n')
3032 aliasMap.set(item.variable, {
3033 variable: item.variable,
3034 });
3035 } else if (item.variable && item.property) {
3036 // Property access like RETURN n.name (no explicit alias)
3037 // In Cypher, you can reference this by the property name alone
3038 aliasMap.set(item.property, {
3039 variable: item.variable,
3040 property: item.property,
3041 });
3042 }
3043 }
3044
3045 return aliasMap;
3046}
3047
3048/**
3049 * Build a map of aliases from WITH clause items.

Callers 1

astToStepsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected