Skip to content

Commit 438406f

Browse files
committed
Java:MultiDataSource 为 SQLAuto 完善 InfluxDB 执行耗时,解决结果集只有 1 条时返回空数组
1 parent 5cb87bc commit 438406f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/boot/DemoController.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,12 +1441,20 @@ public String execute(@RequestBody String request, HttpSession session) {
14411441
long executeStartTime = System.currentTimeMillis();
14421442

14431443
if (DemoSQLConfig.DATABASE_INFLUXDB.equals(database)) {
1444-
JSONObject result = executor.execute(config, false);
1445-
if (isWrite) {
1446-
updateCount = result == null ? 0 : result.getIntValue(JSONResponse.KEY_COUNT);
1447-
} else {
1448-
arr = result == null ? null : result.getJSONArray(DemoSQLExecutor.KEY_RAW_LIST);
1449-
}
1444+
JSONObject result = executor.execute(config, false);
1445+
executeDuration = System.currentTimeMillis() - executeStartTime;
1446+
1447+
if (isWrite) {
1448+
updateCount = result == null ? 0 : result.getIntValue(JSONResponse.KEY_COUNT);
1449+
} else {
1450+
arr = result == null ? null : result.getJSONArray(DemoSQLExecutor.KEY_RAW_LIST);
1451+
if (arr == null) {
1452+
arr = new JSONArray();
1453+
if (result != null) {
1454+
arr.add(result);
1455+
}
1456+
}
1457+
}
14501458
} else {
14511459
Statement statement = executor.getStatement(config, trimmedSQL);
14521460
if (statement instanceof PreparedStatement) {

0 commit comments

Comments
 (0)