Skip to content

Commit cf7bdd7

Browse files
committed
@combine:value 复杂条件组合:解决 key! 报错
1 parent bff0d44 commit cf7bdd7

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,7 @@ public String getWhereString(boolean hasPrefix, RequestMethod method, Map<String
24412441
}
24422442

24432443
key = "";
2444+
lastLogic = 0;
24442445

24452446
if (isOver) {
24462447
break;
@@ -2482,21 +2483,23 @@ else if (c == '|') {
24822483
}
24832484
}
24842485
else if (c == '!') {
2485-
char next = i >= n - 1 ? 0 : s.charAt(i + 1);
2486-
if (next == ' ') {
2487-
throw new IllegalArgumentException(table + ":{ @combine: '" + combine + "' } 中字符 '" + s.substring(0, i + 1)
2488-
+ "' 不合法!非逻辑符 '!' 右边多了一个空格 ' ' !非逻辑符 '!' 右边不允许任何相邻空格 ' ',也不允许 ')' '&' '|' 中任何一个!");
2489-
}
2490-
if (next == ')' || next == '&' || next == '!') {
2491-
throw new IllegalArgumentException(table + ":{ @combine: '" + combine + "' } 中字符 '" + s.substring(0, i + 1)
2492-
+ "' 不合法!非逻辑符 '!' 右边多了一个字符 '" + next + "' !非逻辑符 '!' 右边不允许任何相邻空格 ' ',也不允许 ')' '&' '|' 中任何一个!");
2493-
}
2494-
24952486
last = i <= 0 ? 0 : s.charAt(i - 1); // & | 后面跳过了空格
2496-
if (i > 0 && lastLogic <= 0 && last != '(') {
2497-
throw new IllegalArgumentException(table + ":{ @combine: '" + combine + "' } 中字符 '" + s.substring(i)
2498-
+ "' 不合法!左边缺少 & | 逻辑连接符!逻辑连接符 & | 左右必须各一个相邻空格!空格不能多也不能少!"
2499-
+ "不允许首尾有空格,也不允许连续空格!左括号 ( 的右边 和 右括号 ) 的左边 都不允许有相邻空格!");
2487+
2488+
char next = i >= n - 1 ? 0 : s.charAt(i + 1);
2489+
if (last == ' ' || last == '(') {
2490+
if (next == ' ') {
2491+
throw new IllegalArgumentException(table + ":{ @combine: '" + combine + "' } 中字符 '" + s.substring(0, i + 1)
2492+
+ "' 不合法!非逻辑符 '!' 右边多了一个空格 ' ' !非逻辑符 '!' 右边不允许任何相邻空格 ' ',也不允许 ')' '&' '|' 中任何一个!");
2493+
}
2494+
if (next == ')' || next == '&' || next == '!') {
2495+
throw new IllegalArgumentException(table + ":{ @combine: '" + combine + "' } 中字符 '" + s.substring(0, i + 1)
2496+
+ "' 不合法!非逻辑符 '!' 右边多了一个字符 '" + next + "' !非逻辑符 '!' 右边不允许任何相邻空格 ' ',也不允许 ')' '&' '|' 中任何一个!");
2497+
}
2498+
if (i > 0 && lastLogic <= 0 && last != '(') {
2499+
throw new IllegalArgumentException(table + ":{ @combine: '" + combine + "' } 中字符 '" + s.substring(i)
2500+
+ "' 不合法!左边缺少 & | 逻辑连接符!逻辑连接符 & | 左右必须各一个相邻空格!空格不能多也不能少!"
2501+
+ "不允许首尾有空格,也不允许连续空格!左括号 ( 的右边 和 右括号 ) 的左边 都不允许有相邻空格!");
2502+
}
25002503
}
25012504

25022505
if (next == '(') {

0 commit comments

Comments
 (0)