mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
FIX: append extraWhere to join
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user