Skip to content

Commit 47670c2

Browse files
committed
Server:解决自动化LEFT,RIGHT JOIN不能用query:1,2查total
1 parent 123b365 commit 47670c2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractSQLConfig.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,17 @@ public static List<Join> parseJoin(RequestMethod method, List<Join> joinList, Ca
18761876
SQLConfig joinConfig = newSQLConfig(method, name, j.getTable(), null, callback).setMain(false).setKeyPrefix(true);
18771877
SQLConfig cacheConfig = newSQLConfig(method, name, j.getTable(), null, callback).setCount(1);
18781878

1879+
//解决 query: 1/2 查数量时报错
1880+
/* SELECT count(*) AS count FROM sys.Moment AS Moment
1881+
LEFT JOIN ( SELECT count(*) AS count FROM sys.Comment ) AS Comment ON Comment.momentId = Moment.id LIMIT 1 OFFSET 0 */
1882+
if (RequestMethod.isHeadMethod(method, true)) {
1883+
joinConfig.setMethod(GET); //子查询不能为 SELECT count(*) ,而应该是 SELECT momentId
1884+
joinConfig.setColumn(j.getKey()); //优化性能,不取非必要的字段
1885+
1886+
cacheConfig.setMethod(GET); //子查询不能为 SELECT count(*) ,而应该是 SELECT momentId
1887+
cacheConfig.setColumn(j.getKey()); //优化性能,不取非必要的字段
1888+
}
1889+
18791890
j.setJoinConfig(joinConfig);
18801891
j.setCacheConfig(cacheConfig);
18811892
}

0 commit comments

Comments
 (0)