#2327 - findSingleAttribute() on a ToMany path includes the id column

Follow up refactor SqlTreeBuilder
This commit is contained in:
rbygrave committed 2021-08-24 15:04:23 +12:00
1 parent bedb841fa9
commit d4d9bb204d
1 file changed
+20 -18
@@ -299,15 +299,31 @@ public final class SqlTreeBuilder {
return new SqlTreeNodeRoot(desc, props, myList, withId, includeJoin, lazyLoadMany, temporalMode, disableLazyLoad, sqlDistinct, baseTable); return new SqlTreeNodeRoot(desc, props, myList, withId, includeJoin, lazyLoadMany, temporalMode, disableLazyLoad, sqlDistinct, baseTable);
} else if (prop instanceof STreePropertyAssocMany) { } else if (prop instanceof STreePropertyAssocMany) {
boolean withId = isNotSingleAttribute() && !subQuery; return new SqlTreeNodeManyRoot(prefix, (STreePropertyAssocMany) prop, props, myList, withId(), temporalMode, disableLazyLoad);
return new SqlTreeNodeManyRoot(prefix, (STreePropertyAssocMany) prop, props, myList, withId, temporalMode, disableLazyLoad);
} else { } else {
boolean withId = isNotSingleAttribute() && !subQuery; return new SqlTreeNodeBean(prefix, prop, props, myList, withId(), temporalMode, disableLazyLoad);
return new SqlTreeNodeBean(prefix, prop, props, myList, withId, temporalMode, disableLazyLoad);
} }
} }
boolean withId() {
return isNotSingleAttribute() && !subQuery;
}
/**
* Return true if the Id property should be excluded (as it is automatically included).
*/
private boolean excludeIdProperty() {
return query == null || !query.isSingleAttribute() && !query.isManualId();
}
/**
* Return true if the query is not a single attribute query.
*/
private boolean isNotSingleAttribute() {
return query == null || !query.isSingleAttribute();
}
/** /**
* Build extra joins to support properties used in where clause but not * Build extra joins to support properties used in where clause but not
* already in select clause. * already in select clause.
@@ -666,20 +682,6 @@ public final class SqlTreeBuilder {
} }
return extras.toArray(new String[0]); return extras.toArray(new String[0]);
} }
} }
/**
* Return true if the Id property should be excluded (as it is automatically included).
*/
private boolean excludeIdProperty() {
return query == null || !query.isSingleAttribute() && !query.isManualId();
}
/**
* Return true if the query is not a single attribute query.
*/
private boolean isNotSingleAttribute() {
return query == null || !query.isSingleAttribute();
}
} }