Merge pull request #2300 from FOCONIS/exists-with-dynamic

Enables select + exists for dynamic formula properties
This commit is contained in:
Rob Bygrave
2021-08-11 14:01:46 +12:00
committed by GitHub
3 changed files with 29 additions and 10 deletions
@@ -2519,7 +2519,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
if (propName.indexOf('(') > -1) {
return findSqlTreeFormula(propName, path);
}
return _findBeanProperty(propName);
return findProperty(propName);
}
/**
@@ -365,11 +365,11 @@ public final class SqlTreeBuilder {
* This means it can included individual properties of an embedded bean.
* </p>
*/
private void addPropertyToSubQuery(SqlTreeProperties selectProps, STreeType desc, String propName) {
STreeProperty p = desc.findProperty(propName);
private void addPropertyToSubQuery(SqlTreeProperties selectProps, STreeType desc, String propName, String path) {
STreeProperty p = desc.findPropertyWithDynamic(propName, path);
if (p == null) {
logger.error("property [" + propName + "]not found on " + desc + " for query - excluding it.");
return;
} else if (p instanceof STreePropertyAssoc && p.isEmbedded()) {
// if the property is embedded we need to lookup the real column name
int pos = propName.indexOf('.');
@@ -383,7 +383,7 @@ public final class SqlTreeBuilder {
private void addProperty(SqlTreeProperties selectProps, STreeType desc, OrmQueryProperties queryProps, String propName) {
if (subQuery) {
addPropertyToSubQuery(selectProps, desc, propName);
addPropertyToSubQuery(selectProps, desc, propName, queryProps.getPath());
return;
}