//BUG 3105651: Indicate to the VariableNodes in the subtree
//that they should check the SelectNode before resolving.
//If the variable involved is SELECTed, then we want an empty builder
//instead (with an empty constructor).
boolean oldCheckState = context.shouldCheckSelectNodeBeforeResolving();
((SelectGenerationContext)context).checkSelectNodeBeforeResolving(true);
Expression orderByExpression = getOrderByItem().generateExpression(context);
orderByExpression = getDirection().addToExpression(orderByExpression, context);
((SelectGenerationContext)context).checkSelectNodeBeforeResolving(oldCheckState);
return orderByExpression;