continue;
}
// if we already have a matched symbol, matching again here means it is duplicate/ambiguous
if(matchedSymbol != null) {
if (!matchedSymbol.equals(knownElements.get(j))) {
throw new QueryResolverException("ERR.015.008.0042", QueryPlugin.Util.getString("ERR.015.008.0042", symbolName)); //$NON-NLS-1$ //$NON-NLS-2$
}
continue;
}
matchedSymbol = knownElements.get(j);
position = j;
}
if (matchedSymbol != null) {
TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
symbol.setMetadataID(tempMetadataID);
symbol.setType(matchedSymbol.getType());
}
if (position != -1) {
orderBy.setExpressionPosition(i, position);
continue;
}
}
} else if (sortKey instanceof ExpressionSymbol) {
// check for legacy positional
ExpressionSymbol es = (ExpressionSymbol)sortKey;
if (es.getExpression() instanceof Constant) {
Constant c = (Constant)es.getExpression();
int elementOrder = Integer.valueOf(c.getValue().toString()).intValue();
// adjust for the 1 based index.
if (elementOrder > knownElements.size() || elementOrder < 1) {
throw new QueryResolverException(QueryPlugin.Util.getString("SQLParser.non_position_constant", c)); //$NON-NLS-1$
}
orderBy.setExpressionPosition(i, elementOrder - 1);
continue;
}
}
//handle order by expressions
if (command instanceof SetQuery) {
throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.setquery_order_expression", sortKey)); //$NON-NLS-1$
}
for (ElementSymbol symbol : ElementCollectorVisitor.getElements(sortKey, false)) {
try {
ResolverVisitor.resolveLanguageObject(symbol, fromClauseGroups, command.getExternalGroupContexts(), metadata);
} catch(QueryResolverException e) {
throw new QueryResolverException(e, "ERR.015.008.0043", QueryPlugin.Util.getString("ERR.015.008.0043", symbol.getName()) );//$NON-NLS-1$ //$NON-NLS-2$
}
}
ResolverVisitor.resolveLanguageObject(sortKey, metadata);
int index = expressions.indexOf(SymbolMap.getExpression(sortKey));
if (index == -1 && !isSimpleQuery) {
throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.invalid_unrelated", sortKey)); //$NON-NLS-1$
}
orderBy.setExpressionPosition(i, index);
}
}