Skip to content

Commit bbcb5ba

Browse files
committed
Server:解决key{}:null导致获取对象报错
1 parent 15e0d1b commit bbcb5ba

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql

APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/QueryConfig.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ public static String getLikeString(String key, Object value) {
369369
*/
370370
public static String getRangeString(String key, Object range) throws NotExistException {
371371
Log.i(TAG, "getRangeString key = " + key);
372+
if (range == null) {//依赖的对象都没有给出有效值,这个存在无意义。如果是客户端传的,那就能在客户端确定了。
373+
throw new NotExistException(TAG + "getRangeString(" + key + ", " + range
374+
+ ") range == null");
375+
}
372376

373377
String last = key.isEmpty() ? "" : key.substring(key.length() - 1);
374378
int type = -1;
@@ -390,7 +394,7 @@ public static String getRangeString(String key, Object range) throws NotExistExc
390394

391395
if (range instanceof JSONArray) {
392396
if (type != 0 && type != 2) {
393-
throw new IllegalArgumentException("\"key{}\":[] 中key末尾的逻辑运算符只能用'|','!'中的一种 !");
397+
throw new IllegalArgumentException(key + "{}\":[] 中key末尾的逻辑运算符只能用'|','!'中的一种 !");
394398
}
395399
return key + getInString(key, ((JSONArray) range).toArray(), type == 2);
396400
}
@@ -414,7 +418,7 @@ public static String getRangeString(String key, Object range) throws NotExistExc
414418
return type != 2 ? condition : " NOT " + condition;
415419
}
416420

417-
throw new IllegalArgumentException("\"key{}\":range 中range只能是 用','分隔条件的字符串 或者 可取选项JSONArray!");
421+
throw new IllegalArgumentException(key + "{}\":range 中range只能是 用','分隔条件的字符串 或者 可取选项JSONArray!");
418422
}
419423
/**WHERE key IN ('key0', 'key1', ... )
420424
* @param in

0 commit comments

Comments
 (0)