Skip to content

Commit bbf0fc3

Browse files
committed
前端传 SQL 关键词 OVER 和 AGAINST 去掉多余的空格
1 parent 97fc812 commit bbf0fc3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,10 +1562,10 @@ public String getColumnPrase(String expression, boolean containRaw) {
15621562
// 全文索引 math(name,tag) AGAINST ('a b +c -d' IN NATURALE LANGUAGE MODE) // IN BOOLEAN MODE
15631563

15641564
//有函数,但不是窗口函数
1565-
int overIndex = expression.indexOf(") OVER (");
1566-
int againstIndex = expression.indexOf(") AGAINST (");
1567-
boolean containOver = overIndex > 0 && overIndex < expression.length() - ") OVER (".length();
1568-
boolean containAgainst = againstIndex > 0 && againstIndex < expression.length() - ") AGAINST (".length();
1565+
int overIndex = expression.indexOf(")OVER("); // 传参不传空格,拼接带空格 ") OVER (");
1566+
int againstIndex = expression.indexOf(")AGAINST("); // 传参不传空格,拼接带空格 ") AGAINST (");
1567+
boolean containOver = overIndex > 0 && overIndex < expression.length() - ")OVER(".length();
1568+
boolean containAgainst = againstIndex > 0 && againstIndex < expression.length() - ")AGAINST(".length();
15691569

15701570
if (containOver && containAgainst) {
15711571
throw new IllegalArgumentException("字符 " + expression + " 不合法!"
@@ -1658,8 +1658,9 @@ public String getColumnPrase(String expression, boolean containRaw) {
16581658
// 别名
16591659
String alias = s2.lastIndexOf(":") < s2.lastIndexOf(")") ? null : s2.substring(s2.lastIndexOf(":") + 1);
16601660
// 获取后半部分的参数解析 (agr0 agr1 ...)
1661-
String argsString2[] = parseArgsSplitWithComma(argString2, false, containRaw);
1662-
expression = fun + "(" + StringUtil.getString(agrsString1) + (containOver ? ") OVER (" : ") AGAINST (") + StringUtil.getString(argsString2) + ")" + (StringUtil.isEmpty(alias, true) ? "" : " AS " + quote + alias + quote); }
1661+
String argsString2[] = parseArgsSplitWithComma(argString2, false, containRaw);
1662+
expression = fun + "(" + StringUtil.getString(agrsString1) + (containOver ? ") OVER (" : ") AGAINST (") // 传参不传空格,拼接带空格
1663+
+ StringUtil.getString(argsString2) + ")" + (StringUtil.isEmpty(alias, true) ? "" : " AS " + quote + alias + quote); }
16631664
}
16641665

16651666
return expression;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ public static JSONObject parse(@NotNull final RequestMethod method, String name,
961961
//不在target内的 key:{}
962962
if (rk.startsWith("@") == false && objKeySet.contains(rk) == false) {
963963
if (rv instanceof JSONObject) {
964-
throw new UnsupportedOperationException(method + " 请求," +name + " 里面不允许传 " + rk + ":{} !");
964+
throw new UnsupportedOperationException(method + " 请求," + name + " 里面不允许传 " + rk + ":{} !");
965965
}
966966
if ((method == RequestMethod.POST || method == RequestMethod.PUT) && rv instanceof JSONArray && JSONRequest.isArrayKey(rk)) {
967967
throw new UnsupportedOperationException(method + " 请求," + name + " 里面不允许 " + rk + ":[] 等未定义的 Table[]:[{}] 批量操作键值对!");

0 commit comments

Comments
 (0)