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

Function resolveOrderItem

packages/graph/src/astToSteps.ts:3092–3120  ·  view source on GitHub ↗

* Resolve an ORDER BY item to a direction config for OrderStep. * Handles both property access (n.name) and alias references (value). * * @param useAliasDirectly - If true (WITH ORDER BY), use the alias as the key since * the path has the alias bound after projection. If false (RETURN ORDER BY

(
  order: OrderItem,
  aliasMap: Map<string, AliasInfo>,
  useAliasDirectly: boolean = false,
)

Source from the content-addressed store, hash-verified

3090 * the source property/variable since ordering happens before projection.
3091 */
3092function resolveOrderItem(
3093 order: OrderItem,
3094 aliasMap: Map<string, AliasInfo>,
3095 useAliasDirectly: boolean = false,
3096): {
3097 key?: string;
3098 expression?: ConditionValue;
3099 direction: OrderDirection;
3100 nulls?: "first" | "last";
3101} {
3102 const base =
3103 order.expression !== undefined
3104 ? {
3105 expression: useAliasDirectly
3106 ? convertConditionValue(order.expression)
3107 : resolveReturnOrderExpression(order.expression, aliasMap),
3108 }
3109 : {
3110 key: resolveOrderKey(order, aliasMap, useAliasDirectly),
3111 };
3112
3113 return {
3114 ...base,
3115 direction: order.direction.toLowerCase() as OrderDirection,
3116 ...(order.nulls && {
3117 nulls: order.nulls.toLowerCase() as "first" | "last",
3118 }),
3119 };
3120}
3121
3122function resolveOrderKey(
3123 order: OrderItem,

Callers 2

astToStepsFunction · 0.85
convertWithClauseFunction · 0.85

Calls 3

convertConditionValueFunction · 0.85
resolveOrderKeyFunction · 0.85

Tested by

no test coverage detected