Skip to content

Commit d65c090

Browse files
committed
APIJSONORM:解决 < LEFT JOIN和 > RIGH JOIN 丢主表条件;解决有 @ APP JOIN 会丢前面 JOIN 的条件
1 parent dbb0b17 commit d65c090

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

APIJSON-Java-Server/APIJSONORM/src/main/java/zuo/biao/apijson/server/AbstractSQLConfig.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,10 @@ public String getColumnString(boolean inSQLJoin) throws Exception {
537537

538538
String[] keys = column == null ? null : column.toArray(new String[]{}); //StringUtil.split(c, ";");
539539
if (keys == null || keys.length <= 0) {
540-
540+
541541
boolean noColumn = column != null && inSQLJoin;
542542
String mc = isKeyPrefix() == false ? (noColumn ? "" : "*") : (noColumn ? "" : tableAlias + ".*");
543-
543+
544544
return StringUtil.concat(mc, joinColumn, ", ", true);
545545
}
546546

@@ -1015,14 +1015,12 @@ else if ("!".equals(ce.getKey())) {
10151015

10161016
SQLConfig jc;
10171017
String js;
1018+
1019+
boolean changed = false;
10181020
//各种 JOIN 没办法统一用 & | !连接,只能按优先级,和 @combine 一样?
10191021
for (Join j : joinList) {
10201022
switch (j.getJoinType()) {
10211023
case "@": // APP JOIN
1022-
newWs = whereString; //解决 生成的 SQL 里 where = null
1023-
newPvl = preparedValueList; //解决总是 preparedValueList = new ArrayList
1024-
break;
1025-
10261024
case "<": // LEFT JOIN
10271025
case ">": // RIGHT JOIN
10281026
break;
@@ -1073,14 +1071,17 @@ else if ("!".equals(ce.getKey())) {
10731071
newPvl.addAll(jc.getPreparedValueList());
10741072
}
10751073

1074+
changed = true;
10761075
break;
10771076
default:
10781077
throw new UnsupportedOperationException("join:value 中 value 里的 " + j.getJoinType() + "/" + j.getPath() + "错误!不支持 " + j.getJoinType() + " 等 [@ APP, < LEFT, > RIGHT, | FULL, & INNER, ! OUTTER, ^ SIDE, * CROSS] 之外的JOIN类型 !");
10791078
}
10801079
}
10811080

1082-
whereString = newWs;
1083-
preparedValueList = newPvl;
1081+
if (changed) {
1082+
whereString = newWs;
1083+
preparedValueList = newPvl;
1084+
}
10841085
}
10851086

10861087
String s = whereString.isEmpty() ? "" : (hasPrefix ? " WHERE " : "") + whereString;

0 commit comments

Comments
 (0)