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

Function buildWithAliasMap

packages/graph/src/astToSteps.ts:3052–3082  ·  view source on GitHub ↗

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

(items: WithItem[])

Source from the content-addressed store, hash-verified

3050 * Maps alias name → underlying variable/property info.
3051 */
3052function buildWithAliasMap(items: WithItem[]): Map<string, AliasInfo> {
3053 const aliasMap = new Map<string, AliasInfo>();
3054
3055 for (const item of items) {
3056 const expr = item.expression;
3057 // Handle null literal: WITH null AS x
3058 if (expr === null) {
3059 aliasMap.set(item.alias, {
3060 variable: item.alias,
3061 });
3062 } else if (expr.type === "VariableRef") {
3063 // Variable reference like `WITH n` or `WITH n AS alias`
3064 aliasMap.set(item.alias, {
3065 variable: expr.variable,
3066 });
3067 } else if (expr.type === "PropertyAccess") {
3068 // Property access like `WITH n.name AS name`
3069 aliasMap.set(item.alias, {
3070 variable: expr.variable,
3071 property: expr.property,
3072 });
3073 } else {
3074 // Complex expression (WithAggregate, FunctionCall) - just track the alias itself
3075 aliasMap.set(item.alias, {
3076 variable: item.alias,
3077 });
3078 }
3079 }
3080
3081 return aliasMap;
3082}
3083
3084/**
3085 * Resolve an ORDER BY item to a direction config for OrderStep.

Callers 1

convertWithClauseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected