[bug] PUT "key<>":[] 居然转成了 key = '[]' #276
原代码
AbstractObjectParser
else if (method == PUT && value instanceof JSONArray && (whereList == null || whereList.contains(key) == false))
修改为
else if (method == PUT
&& value instanceof JSONArray
&& (whereList == null || whereList.contains(key) == false)
&& (StringUtil.isName(key)
|| ((key.endsWith("+") || key.endsWith("-")) && StringUtil.isName(key.substring(0, key.length()-1)))))
注释:"key+"和"key-"只用于PUT请求,判断的时候兼顾这种特殊情况
原代码
AbstractSQLConfig
if (isWhere || (StringUtil.isName(key) == false)) {
tableWhere.put(key, value);
if (whereList == null || whereList.contains(key) == false) {
andList.add(key);
}
}
修改为
if (isWhere || (StringUtil.isName(key) == false)) {
tableWhere.put(key, value);
if (whereList == null || whereList.contains(key) == false) {
andList.add(key);
}
}
注释:将"key<>"和"key<"等作为条件
测试
{
"Moment": {
"id": 15,
"content": "test",
"userId>": 82001
},
"tag": "Moment",
"@explain": true
}
"sql": "UPDATE sys.Moment SET content = 'test' WHERE ( (id = 15) AND (userId > 82001) ) LIMIT 1"
{
"Moment": {
"id": 15,
"content": "test",
"praiseUserIdList<>": [
82002
]
},
"tag": "Moment",
"@explain": true
}
"sql": "UPDATE sys.Moment SET content = 'test' WHERE ( (id = 15) AND (praiseUserIdList is NOT null AND (json_contains(praiseUserIdList, '82002'))) ) LIMIT 1"
{
"Moment": {
"id": 15,
"praiseUserIdList<>": [
82002
],
"praiseUserIdList+": [
920
]
},
"tag": "Moment",
"@explain": true
}
"sql": "UPDATE sys.Moment SET praiseUserIdList = '[82002,70793,38710,93793,82001,960]' WHERE ( (id = 15) AND (praiseUserIdList is NOT null AND (json_contains(praiseUserIdList, '82002'))) ) LIMIT 1"
APIAuto回归测试也能通过
说明
测试的时候通过重写verify()方法去掉了登录和鉴权
@Override
public void verifyLogin() throws Exception {
//super.verifyLogin();
}
@Override
public boolean verifyAccess(SQLConfig config) throws Exception {
return true;
}
[bug] PUT "key<>":[] 居然转成了 key = '[]' #276
原代码
修改为
注释:"key+"和"key-"只用于PUT请求,判断的时候兼顾这种特殊情况
原代码
修改为
注释:将"key<>"和"key<"等作为条件
测试
{ "Moment": { "id": 15, "content": "test", "userId>": 82001 }, "tag": "Moment", "@explain": true }"sql": "UPDATE
sys.MomentSETcontent= 'test' WHERE ( (id= 15) AND (userId> 82001) ) LIMIT 1"{ "Moment": { "id": 15, "content": "test", "praiseUserIdList<>": [ 82002 ] }, "tag": "Moment", "@explain": true }"sql": "UPDATE
sys.MomentSETcontent= 'test' WHERE ( (id= 15) AND (praiseUserIdListis NOT null AND (json_contains(praiseUserIdList, '82002'))) ) LIMIT 1"{ "Moment": { "id": 15, "praiseUserIdList<>": [ 82002 ], "praiseUserIdList+": [ 920 ] }, "tag": "Moment", "@explain": true }"sql": "UPDATE
sys.MomentSETpraiseUserIdList= '[82002,70793,38710,93793,82001,960]' WHERE ( (id= 15) AND (praiseUserIdListis NOT null AND (json_contains(praiseUserIdList, '82002'))) ) LIMIT 1"APIAuto回归测试也能通过
说明
测试的时候通过重写verify()方法去掉了登录和鉴权