#2753 - Fix for, Bug findSingleAttributeList o2m distinct

This commit is contained in:
Rob Bygrave
2022-07-29 17:12:51 +12:00
parent 02ead0bcdb
commit fa9e9be003
3 changed files with 6 additions and 8 deletions
@@ -458,8 +458,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
/**
* Return the many property that is fetched in the query or null if there is not one.
*/
public BeanPropertyAssocMany<?> manyProperty() {
return manyProperty;
public BeanPropertyAssocMany<?> manyPropertyForOrderBy() {
return query.isSingleAttribute() ? null : manyProperty;
}
/**
@@ -225,7 +225,7 @@ public final class CQueryPredicates {
*/
private void parsePropertiesToDbColumns(DeployParser deployParser) {
// order by is dependent on the manyProperty (if there is one)
String logicalOrderBy = deriveOrderByWithMany(request.manyProperty());
String logicalOrderBy = deriveOrderByWithMany(request.manyPropertyForOrderBy());
if (logicalOrderBy != null) {
dbOrderBy = deployParser.parse(logicalOrderBy);
}
@@ -234,7 +234,7 @@ public final class CQueryPredicates {
dbWhere = deriveWhere(deployParser);
dbFilterMany = deriveFilterMany(deployParser);
dbHaving = deriveHaving(deployParser);
// all includes including ones for manyWhere clause
// all includes, including ones for manyWhere clause
predicateIncludes = deployParser.getIncludes();
}
@@ -293,8 +293,7 @@ public final class CQueryPredicates {
}
/**
* There is a many property so we need to make sure the ordering is
* appropriate.
* There is a many property we need to make sure the ordering is appropriate.
*/
private String deriveOrderByWithMany(BeanPropertyAssocMany<?> manyProp) {
if (manyProp == null) {
@@ -757,8 +757,7 @@ public class TestQuerySingleAttribute extends BaseTestCase {
}
@Test
public void oneToMany_distinct() {
void oneToMany_distinct() {
ResetBasicData.reset();
Query<Customer> query = DB.find(Customer.class)