Skip to content

Commit cf1cca0

Browse files
committed
解决 "toId%": "0,10" 等连续范围报错 value 类型不合法;解决 "id{}@": "[]/Moment/praiseUserIdList" 等引用赋值的值有时类型为 List 时报错 ArrayList cannot be cast to JSONArray;
1 parent 5a73b23 commit cf1cca0

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,10 @@ public String getRegExpString(String key, String value, boolean ignoreCase) {
19201920
* @throws IllegalArgumentException
19211921
*/
19221922
@JSONField(serialize = false)
1923-
public String getBetweenString(String key, Object value) throws IllegalArgumentException {
1923+
public String getBetweenString(String key, Object value, String rawSQL) throws IllegalArgumentException {
1924+
if (rawSQL != null) {
1925+
throw new UnsupportedOperationException("@raw:value 中 " + key + " 不合法!@raw 不支持 key% 这种功能符 !只支持 key, key!, key<, key{} 等比较运算 和 @column, @having !");
1926+
}
19241927
if (value == null) {
19251928
return "";
19261929
}
@@ -1960,7 +1963,7 @@ public String getBetweenString(String key, Object[] values, int type) throws Ill
19601963
throw new IllegalArgumentException(key + "%:value 中 value 不合法!类型为 String 时必须包括1个逗号 , 且左右两侧都有值!类型为 String[] 里面每个元素要符合前面类型为 String 的规则 !");
19611964
}
19621965

1963-
condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) + "(" + getBetweenString(key, vs[0], vs[1]) + ")";
1966+
condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) + "(" + getBetweenString(key, (Object) vs[0], (Object) vs[1]) + ")";
19641967
}
19651968

19661969
return getCondition(Logic.isNot(type), condition);
@@ -2149,6 +2152,9 @@ public String getExistsString(String key, Object value, String rawSQL) throws Ex
21492152
*/
21502153
@JSONField(serialize = false)
21512154
public String getContainString(String key, Object value, String rawSQL) throws IllegalArgumentException {
2155+
if (rawSQL != null) {
2156+
throw new UnsupportedOperationException("@raw:value 中 " + key + " 不合法!@raw 不支持 key<> 这种功能符 !只支持 key, key!, key<, key{} 等比较运算 和 @column, @having !");
2157+
}
21522158
if (value == null) {
21532159
return "";
21542160
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ public boolean verifyAccess(SQLConfig config) throws Exception {
262262

263263
//key!{}:[] 或 其它没有明确id的条件 等 可以和key{}:list组合。类型错误就报错
264264
requestId = (Number) config.getWhere(visitorIdkey, true);//JSON里数值不能保证是Long,可能是Integer
265-
JSONArray requestIdArray = (JSONArray) config.getWhere(visitorIdkey + "{}", true);//不能是 &{}, |{} 不要传,直接{}
265+
@SuppressWarnings("unchecked")
266+
Collection<Object> requestIdArray = (Collection<Object>) config.getWhere(visitorIdkey + "{}", true);//不能是 &{}, |{} 不要传,直接{}
266267
if (requestId != null) {
267268
if (requestIdArray == null) {
268269
requestIdArray = new JSONArray();

0 commit comments

Comments
 (0)