if (i > 0)
buf.append(", ");
StringBuffer ordComp = new StringBuffer();
Ordering ord = (Ordering) list.get(i);
//UPPER is (I think) part of the SQL99 standard, and I'm not convinced it's universally available
// - should the syntax used here be defined by the Db specific adaptor perhaps, or at least
// possibly specified by the db adaptor (a DB specific OrderingTranslator hook)?
if (ord.isCaseInsensitive()) {
ordComp.append("UPPER(");
}
Expression exp = ord.getSortSpec();
if (exp.getType() == Expression.OBJ_PATH) {
appendObjPath(ordComp, exp);
} else if (exp.getType() == Expression.DB_PATH) {
appendDbPath(ordComp, exp);
} else {
throw new CayenneRuntimeException(
"Unsupported ordering expression: " + exp);
}
//Close UPPER() modifier
if (ord.isCaseInsensitive()) {
ordComp.append(")");
}
orderByColumnList.add(ordComp.toString());
buf.append(ordComp.toString());
// "ASC" is a noop, omit it from the query
if (!ord.isAscending()) {
buf.append(" DESC");
}
}
return buf.length() > 0 ? buf.toString() : null;