* @return The name of the sort property that was added to the primary
* datastore query.
*/
String getSortProperty(QueryData qd, Expression expr) {
OrderExpression oe = (OrderExpression) expr;
PrimaryExpression left = (PrimaryExpression) oe.getLeft();
AbstractClassMetaData acmd = qd.acmd;
List<String> tuples = getTuples(left, qd.compilation.getCandidateAlias());
if (isJoin(left.getLeft(), tuples)) {
// Change the class meta data to the meta-data for the joined class
acmd = getJoinClassMetaData(left.getLeft(), tuples, qd);
}
AbstractMemberMetaData ammd = getMemberMetaData(acmd, tuples);
if (ammd == null) {
throw noMetaDataException(left.getId(), acmd.getFullClassName());
}
if (isParentPK(ammd)) {
throw new UnsupportedDatastoreFeatureException("Cannot sort by parent.");
} else {
String sortProp;