Allow non-domain sort orders to be used with R2dbcQueryCreator.

Closes #1548
This commit is contained in:
Mark Paluch
2023-06-30 10:42:55 +02:00
parent f1ece358a1
commit e2514a3454
2 changed files with 21 additions and 13 deletions

View File

@@ -136,7 +136,7 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> {
}
if (sort.isSorted()) {
selectSpec = selectSpec.withSort(getSort(sort));
selectSpec = selectSpec.withSort(sort);
}
if (tree.isDistinct()) {
@@ -186,15 +186,4 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> {
return expressions.toArray(new Expression[0]);
}
private Sort getSort(Sort sort) {
RelationalPersistentEntity<?> tableEntity = entityMetadata.getTableEntity();
List<Sort.Order> orders = sort.get().map(order -> {
RelationalPersistentProperty property = tableEntity.getRequiredPersistentProperty(order.getProperty());
return order.isAscending() ? Sort.Order.asc(property.getName()) : Sort.Order.desc(property.getName());
}).collect(Collectors.toList());
return Sort.by(orders);
}
}