Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复PUT方法key的问题 #5

Open
chenyanlann opened this issue Sep 7, 2021 · 0 comments
Open

修复PUT方法key的问题 #5

chenyanlann opened this issue Sep 7, 2021 · 0 comments

Comments

@chenyanlann
Copy link
Owner

[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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant