String sql = buildMainQuery(orderBy, request, predicates, rsql);
SpiQuery<?> query = request.getQuery();
if (query.hasMaxRowsOrFirstRow() && sqlLimiter != null) {
// wrap with a limit offset or ROW_NUMBER() etc
return sqlLimiter.limit(new OrmQueryLimitRequest(sql, orderBy, query, dbPlatform));
} else {
// add back select keyword (it was removed to support sqlQueryLimiter)
String prefix = "select "+ (rsql.isDistinct() ? "distinct " : "");
sql = prefix + sql;