FIX: append extraWhere to join

This commit is contained in:
Roland Praml
2018-11-10 23:42:02 +01:00
parent 1b2bfc5df8
commit c5536aaeec
4 changed files with 30 additions and 26 deletions
@@ -510,6 +510,17 @@ class SqlTreeNodeBean implements SqlTreeNode {
ctx.append(inheritInfo.getWhere()).append(" ");
}
}
appendExtraWhere(ctx);
for (SqlTreeNode aChildren : children) {
// recursively add to the where clause any
// fixed predicates (extraWhere etc)
aChildren.appendWhere(ctx);
}
}
protected void appendExtraWhere(DbSqlContext ctx) {
if (extraWhere != null) {
if (ctx.length() > 0) {
ctx.append(" and");
@@ -518,12 +529,6 @@ class SqlTreeNodeBean implements SqlTreeNode {
String ew = StringHelper.replaceString(extraWhere, "${ta}", ta);
ctx.append(" ").append(ew).append(" ");
}
for (SqlTreeNode aChildren : children) {
// recursively add to the where clause any
// fixed predicates (extraWhere etc)
aChildren.appendWhere(ctx);
}
}
/**
@@ -604,7 +609,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
return sqlJoinType;
}
private SqlJoinType appendFromAsJoin(DbSqlContext ctx, SqlJoinType joinType) {
protected SqlJoinType appendFromAsJoin(DbSqlContext ctx, SqlJoinType joinType) {
if (nodeBeanProp instanceof STreePropertyAssocMany) {
STreePropertyAssocMany manyProp = (STreePropertyAssocMany) nodeBeanProp;
@@ -41,6 +41,22 @@ final class SqlTreeNodeManyRoot extends SqlTreeNodeBean {
return detailBean;
}
/**
* append extraWhere to the join.
*/
@Override
protected SqlJoinType appendFromAsJoin(DbSqlContext ctx, SqlJoinType joinType) {
SqlJoinType join = super.appendFromAsJoin(ctx, joinType);
super.appendExtraWhere(ctx);
return join;
}
@Override
protected void appendExtraWhere(DbSqlContext ctx) {
// extraWhere is already appended to the tableJoin
}
/**
* Force outer join for everything after the many property.
*/