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

请求新增接口http://localhost:8080/post #218

Closed
gujiachun opened this issue Apr 19, 2021 · 1 comment · Fixed by #219
Closed

请求新增接口http://localhost:8080/post #218

gujiachun opened this issue Apr 19, 2021 · 1 comment · Fixed by #219

Comments

@gujiachun
Copy link

版本:v4.6.7
1)执行http://localhost:8080/post
{
"Moment":{
"content":"adsfasdfasdfasdf"
},
"tag":"Moment"
}
可以成功执行
2)但如果我需要看执行性能
{
"Moment":{
"content":"adsfasdfasdfasdf"
},
"tag":"Moment",
"@Explain":true
}
就会报异常。

异常代码:
`boolean explain = config.isExplain();
if (explain) { //如果先执行 explain,则 execute 会死循环,所以只能先执行非 explain
config.setExplain(false); //对下面 config.getSQL(false); 生效
JSONObject res = getSQLExecutor().execute(config, false);

                            //执行了第二次导致的错误
			config.setExplain(explain);
			JSONObject explainResult = config.isMain() && config.getPosition() != 0 ? null : getSQLExecutor().execute(config, false);

			if (explainResult == null) {
				result = res;
			}
			else {
				result = new JSONObject(true);
				result.put(KEY_EXPLAIN, explainResult);
				result.putAll(res);
			}
		}`
@TommyLemon
Copy link
Collaborator

TommyLemon commented Apr 19, 2021

SQL 对 SELECT 外的操作不支持 EXPLAIN。这里应该只对 RequestMethod.isQueryMethod(config.getMethod, true) 执行 EXPLAIN SQL,其它的操作直接 return 一个只有 "sql": config.getSQL(false) 这个键值对的 JSONObject。

感谢反馈,可以提个 Pull Request,会把你加到贡献者列表里哦
https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md

gujiachun pushed a commit to gujiachun/APIJSON that referenced this issue Apr 20, 2021
explain只应用在select请求中,如果是更新请求 不需要执行explain,但可以返回sql语句

issue Tencent#218
closes Tencent#218
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

Successfully merging a pull request may close this issue.

2 participants