@@ -768,7 +768,7 @@ public String getHavingString(boolean hasPrefix) {
768768 continue ;
769769 }
770770
771- int end = expression .indexOf (")" );
771+ int end = expression .lastIndexOf (")" );
772772 if (start >= end ) {
773773 throw new IllegalArgumentException ("字符 " + expression + " 不合法!"
774774 + "@having:value 中 value 里的 SQL函数必须为 function(arg0,arg1,...) 这种格式!" );
@@ -1040,13 +1040,28 @@ public String getColumnString(boolean inSQLJoin) throws Exception {
10401040 index = c .lastIndexOf (":" ); //StringUtil.split返回数组中,子项不会有null
10411041 origin = index < 0 ? c : c .substring (0 , index );
10421042 alias = index < 0 ? null : c .substring (index + 1 );
1043- if (StringUtil .isName (origin ) == false || (alias != null && StringUtil .isName (alias ) == false )) {
1044- throw new IllegalArgumentException ("HEAD请求: 预编译模式下 @column:value 中 value里面用 , 分割的每一项"
1043+
1044+ if (alias != null && StringUtil .isName (alias ) == false ) {
1045+ throw new IllegalArgumentException ("HEAD请求: 字符 " + alias + " 不合法!预编译模式下 @column:value 中 value里面用 , 分割的每一项"
10451046 + " column:alias 中 column 必须是1个单词!如果有alias,则alias也必须为1个单词!并且不要有多余的空格!" );
10461047 }
1048+
1049+ if (StringUtil .isName (origin ) == false ) {
1050+ int start = origin .indexOf ("(" );
1051+ if (start < 0 || origin .lastIndexOf (")" ) <= start ) {
1052+ throw new IllegalArgumentException ("HEAD请求: 字符" + origin + " 不合法!预编译模式下 @column:value 中 value里面用 , 分割的每一项"
1053+ + " column:alias 中 column 必须是1个单词!如果有alias,则alias也必须为1个单词!并且不要有多余的空格!" );
1054+ }
1055+
1056+ if (start > 0 && StringUtil .isName (origin .substring (0 , start )) == false ) {
1057+ throw new IllegalArgumentException ("HEAD请求: 字符 " + origin .substring (0 , start ) + " 不合法!预编译模式下 @column:value 中 value里面用 , 分割的每一项"
1058+ + " column:alias 中 column 必须是1个单词!如果有alias,则alias也必须为1个单词!并且不要有多余的空格!" );
1059+ }
1060+ }
10471061 }
10481062 }
1049- return SQL .count (column != null && column .size () == 1 ? getKey (Pair .parseEntry (column .get (0 ), true ).getKey ()) : "*" );
1063+
1064+ return SQL .count (column != null && column .size () == 1 && StringUtil .isName (column .get (0 )) ? getKey (column .get (0 )) : "*" );
10501065 case POST :
10511066 if (column == null || column .isEmpty ()) {
10521067 throw new IllegalArgumentException ("POST 请求必须在Table内设置要保存的 key:value !" );
@@ -1151,7 +1166,7 @@ public String getColumnString(boolean inSQLJoin) throws Exception {
11511166 int start = expression .indexOf ("(" );
11521167 int end = 0 ;
11531168 if (start >= 0 ) {
1154- end = expression .indexOf (")" );
1169+ end = expression .lastIndexOf (")" );
11551170 if (start >= end ) {
11561171 throw new IllegalArgumentException ("字符 " + expression + " 不合法!"
11571172 + "@column:value 中 value 里的 SQL函数必须为 function(arg0,arg1,...) 这种格式!" );
@@ -2254,7 +2269,7 @@ else if (range instanceof String) {//非Number类型需要客户端拼接成 < '
22542269
22552270 if (rawSQL != null ) {
22562271 int index = rawSQL == null ? -1 : rawSQL .indexOf ("(" );
2257- condition = (index >= 0 && index < rawSQL .indexOf (")" ) ? "" : getKey (k ) + " " ) + rawSQL ;
2272+ condition = (index >= 0 && index < rawSQL .lastIndexOf (")" ) ? "" : getKey (k ) + " " ) + rawSQL ;
22582273 }
22592274
22602275 // 还是只支持整段为 Raw SQL 比较好
@@ -2299,7 +2314,7 @@ else if (isPrepared() && (c.contains("--") || PATTERN_RANGE.matcher(c).matches()
22992314
23002315 index = c == null ? -1 : c .indexOf ("(" );
23012316 condition += ((i <= 0 ? "" : (logic .isAnd () ? AND : OR )) //连接方式
2302- + (index >= 0 && index < c .indexOf (")" ) ? "" : getKey (k ) + " " ) //函数和非函数条件
2317+ + (index >= 0 && index < c .lastIndexOf (")" ) ? "" : getKey (k ) + " " ) //函数和非函数条件
23032318 + c ); // 还是只支持整段为 Raw SQL 比较好 (appendRaw && index > 0 ? rawSQL : "") + c); //单个条件,如果有 Raw SQL 则按原来位置拼接
23042319 }
23052320 }
0 commit comments