@@ -181,8 +181,6 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
181181
182182 ResultSet rs = null ;
183183
184- boolean noCache = true ;
185-
186184 if (unknowType ) {
187185 Statement statement = getStatement (config );
188186 rs = execute (statement , sql );
@@ -229,9 +227,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
229227
230228 case GET :
231229 case GETS :
232- noCache = config .isTest () || config .isExplain (); // TODO explain 照样 cache,但下面的 noCache 涉及的地方要改改,尤其是 JOIN
233-
234- result = noCache ? null : getCacheItem (sql , position , config .getCache ());
230+ result = getCacheItem (sql , position , config .getCache ());
235231 Log .i (TAG , ">>> select result = getCache('" + sql + "', " + position + ") = " + result );
236232 if (result != null ) {
237233 cachedSQLCount ++;
@@ -282,7 +278,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
282278 // }
283279
284280 // bugfix-修复非常规数据库字段,获取表名失败导致输出异常
285- if (noCache == false && hasJoin && viceColumnStart > length ) {
281+ if (config . isExplain () == false && hasJoin && viceColumnStart > length ) {
286282 List <String > column = config .getColumn ();
287283
288284 if (column != null && column .isEmpty () == false ) {
@@ -293,7 +289,7 @@ else if (config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i)) == false) {
293289 }
294290 }
295291
296- item = onPutColumn (config , rs , rsmd , index , item , i , noCache == false && hasJoin && i >= viceColumnStart ? childMap : null );
292+ item = onPutColumn (config , rs , rsmd , index , item , i , config . isExplain () == false && hasJoin && i >= viceColumnStart ? childMap : null );
297293 }
298294
299295 resultList = onPutTable (config , rs , rsmd , resultList , index , item );
@@ -321,19 +317,17 @@ else if (config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i)) == false) {
321317
322318 // @ APP JOIN 查询副表并缓存到 childMap >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
323319
324- if (noCache == false ) {
325- //子查询 SELECT Moment.*, Comment.id 中的 Comment 内字段
326- Set <Entry <String , JSONObject >> set = childMap .entrySet ();
327-
328- //<sql, Table>
329- for (Entry <String , JSONObject > entry : set ) {
330- List <JSONObject > l = new ArrayList <>();
331- l .add (entry .getValue ());
332- putCache (entry .getKey (), l , JSONRequest .CACHE_ROM );
333- }
320+ //子查询 SELECT Moment.*, Comment.id 中的 Comment 内字段
321+ Set <Entry <String , JSONObject >> set = childMap .entrySet ();
334322
335- putCache (sql , resultList , config .getCache ());
323+ //<sql, Table>
324+ for (Entry <String , JSONObject > entry : set ) {
325+ List <JSONObject > l = new ArrayList <>();
326+ l .add (entry .getValue ());
327+ putCache (entry .getKey (), l , JSONRequest .CACHE_ROM );
336328 }
329+
330+ putCache (sql , resultList , config .getCache ());
337331 Log .i (TAG , ">>> select putCache('" + sql + "', resultList); resultList.size() = " + resultList .size ());
338332
339333 long endTime = System .currentTimeMillis ();
0 commit comments