Skip to content

Commit 57920dc

Browse files
committed
Server:解决 explain 拿到的字段不完整
1 parent e9e0f6d commit 57920dc

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

APIJSON-Java-Server/APIJSONORM/src/main/java/zuo/biao/apijson/server/AbstractParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,11 +859,14 @@ public JSONArray onArrayParse(JSONObject request, String parentPath, String name
859859

860860
int len = explain || isSubquery ? 1 : size;
861861
JSONObject parent;
862-
for (int i = 0; i < len; i++) { //生成len个
862+
for (int i = 0; i < len; i++) { //生成len个, config.setType(SQLConfig.TYPE_ITEM) 每次都必要,因为内部会设置成其它值
863863
parent = onObjectParse(request, path, "" + i, config.setType(SQLConfig.TYPE_ITEM).setPosition(i), isSubquery);
864864
if (parent == null || parent.isEmpty()) {
865865
break;
866866
}
867+
if (explain) {
868+
parent.put(JSONRequest.KEY_EXPLAIN, explain);
869+
}
867870
//key[]:{Table:{}}中key equals Table时 提取Table
868871
response.add(getValue(parent, childKeys)); //null有意义
869872
}

APIJSON-Java-Server/APIJSONORM/src/main/java/zuo/biao/apijson/server/AbstractSQLExecutor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
181181

182182
ResultSet rs = null;
183183

184-
boolean noCache = false; // true;
184+
boolean noCache = true;
185185

186186
if (unknowType) {
187187
Statement statement = getStatement(config);
@@ -229,7 +229,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
229229

230230
case GET:
231231
case GETS:
232-
// noCache = config.isExplain() || config.isTest();
232+
noCache = config.isExplain() || config.isTest();
233233

234234
result = noCache ? null : getCacheItem(sql, position, config.getCache());
235235
Log.i(TAG, ">>> select result = getCache('" + sql + "', " + position + ") = " + result);
@@ -282,7 +282,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
282282
// }
283283

284284
// bugfix-修复非常规数据库字段,获取表名失败导致输出异常
285-
if (hasJoin && viceColumnStart > length) {
285+
if (noCache == false && hasJoin && viceColumnStart > length) {
286286
List<String> column = config.getColumn();
287287

288288
if (column != null && column.isEmpty() == false) {
@@ -293,7 +293,7 @@ else if (config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i)) == false) {
293293
}
294294
}
295295

296-
item = onPutColumn(config, rs, rsmd, index, item, i, hasJoin && i >= viceColumnStart ? childMap : null);
296+
item = onPutColumn(config, rs, rsmd, index, item, i, noCache == false && hasJoin && i >= viceColumnStart ? childMap : null);
297297
}
298298

299299
resultList = onPutTable(config, rs, rsmd, resultList, index, item);
@@ -321,7 +321,7 @@ else if (config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i)) == false) {
321321

322322
// @ APP JOIN 查询副表并缓存到 childMap >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
323323

324-
// if (noCache == false) {
324+
if (noCache == false) {
325325
//子查询 SELECT Moment.*, Comment.id 中的 Comment 内字段
326326
Set<Entry<String, JSONObject>> set = childMap.entrySet();
327327

@@ -333,7 +333,7 @@ else if (config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i)) == false) {
333333
}
334334

335335
putCache(sql, resultList, config.getCache());
336-
// }
336+
}
337337
Log.i(TAG, ">>> select putCache('" + sql + "', resultList); resultList.size() = " + resultList.size());
338338

339339
long endTime = System.currentTimeMillis();

0 commit comments

Comments
 (0)