Repository navigation
[Bug] global @explain doesn't work #851
Copy link
Copy link
Closed
Labels
Description
APIJSON Version/APIJSON 版本号
8.0.2
Database Type & Version/数据库类型及版本号
MySQL 8.4.5
Environment/环境信息
- JDK/基础库: 17.0.2
- OS/系统: Linux 5.10.134APIAuto Screenshots/APIAuto 请求与结果完整截屏
Current Behavior/问题描述
no SQL returned
POST http://apijson.cn:8080/get
{
"User": {
"id": 82001
},
"[]": {
"Comment": {
"userId@": "User/id"
}
},
"@explain": true
}
{
"User": {
"id": 82001,
"sex": 1,
"name": "Test User",
"head": "https://static.oschina.net/uploads/user/1174/2348263_50.png?t=1439773471000",
"contactIdList": [
82034,
82005,
82030,
82046,
1493748615711,
38710,
82054,
82026,
82012
],
"pictureList": [
"https://common.cnblogs.com/images/icon_weibo_24.png"
],
"date": "2017-02-01 19:21:50.0"
},
"[]": [
{
"Comment": {
"id": 114,
"toId": 0,
"userId": 82001,
"momentId": 371,
"date": "2017-03-02 13:56:06.0",
"content": "test multi put"
}
},
{
"Comment": {
"id": 124,
"toId": 0,
"userId": 82001,
"momentId": 301,
"date": "2017-03-02 13:56:06.0",
"content": "test multi put"
}
},
{
"Comment": {
"id": 160,
"toId": 0,
"userId": 82001,
"momentId": 235,
"date": "2017-03-02 13:56:06.0",
"content": "This is a Content...-160"
}
},
{
"Comment": {
"id": 163,
"toId": 0,
"userId": 82001,
"momentId": 235,
"date": "2017-03-02 13:56:06.0",
"content": "This is a Content...-163"
}
},
{
"Comment": {
"id": 167,
"toId": 0,
"userId": 82001,
"momentId": 58,
"date": "2017-03-25 19:48:41.0",
"content": "Nice!"
}
},
{
"Comment": {
"id": 172,
"toId": 162,
"userId": 82001,
"momentId": 12,
"date": "2017-03-25 20:22:58.0",
"content": "OK"
}
},
{
"Comment": {
"id": 182,
"toId": 110,
"userId": 82001,
"momentId": 371,
"date": "2017-03-26 14:12:52.0",
"content": "hahaha"
}
},
{
"Comment": {
"id": 188,
"toId": 97,
"userId": 82001,
"momentId": 58,
"date": "2017-03-26 15:21:32.0",
"content": "1646"
}
},
{
"Comment": {
"id": 190,
"toId": 0,
"userId": 82001,
"momentId": 58,
"date": "2017-03-26 15:22:13.0",
"content": "dbdj"
}
},
{
"Comment": {
"id": 206,
"toId": 54,
"userId": 82001,
"momentId": 170,
"date": "2017-03-29 11:04:23.0",
"content": "ejej"
}
}
],
"ok": true,
"code": 200,
"msg": "success",
"debug:info|help": " \n提 bug 请发请求和响应的【完整截屏】,没图的自行解决! \n开发者有限的时间和精力主要放在【维护项目源码和文档】上! \n【描述不详细】 或 【文档/常见问题 已有答案】 的问题可能会被忽略!! \n【态度 不文明/不友善】的可能会被踢出群,问题也可能不予解答!!! \n\n **环境信息** \n系统: Linux 5.10.134-19.1.al8.x86_64 \n数据库: DEFAULT_DATABASE = MYSQL \nJDK: 17.0.2 amd64 \nAPIJSON: 8.0.2 \n \n【常见问题】:https://github.com/Tencent/APIJSON/issues/36 \n【通用文档】:https://github.com/Tencent/APIJSON/blob/master/Document.md \n【视频教程】:https://search.bilibili.com/all?keyword=APIJSON",
"time": 1771703494039,
"sql:generate|cache|execute|maxExecute": "2|0|2|2000",
"depth:count|max": "3|5",
"time:start|duration|end|parse|sql": "1771703493968|71|1771703494039|6|65"
}
Expected Behavior/期望结果
Any additional comments?/其它补充说明?
Reactions are currently unavailable
Activity
TommyLemon commentedon Feb 21, 2026
seperately using @Explain can work fine

Zhengcy05 commentedon Jun 11, 2026
Hi👋, I checked the implementation.
@explainis parsed as a global option inAbstractParser, and the docs also say the global value should be propagated into table objects by default.But in
AbstractObjectParser, when propagating the global options, it does:Boolean exp = parser.getGlobalExplain();if (sch != null)before puttingKEY_EXPLAINSo the global
@explainis only applied when a global@schemais also present. That explains why@explainworks when set inside a table object, but not when set only at the root level.The minimal fix should be to change that condition to check
expinstead ofsch, and add a regression test for root-level@explainwithout@schema.If this direction looks good, I can work on a PR.
TommyLemon commentedon Jun 11, 2026
@Zhengcy05 I think the reason I've made this stupid bug is that I copied and pasted another code snippet while forgotten to edit all needed variable names for global explain.
Finally, you helped me and the user of APIJSON with enthusiasm and carefulness.
Thanks for your contribution~