Skip to content

Commit 5f94a63

Browse files
committed
不启用 WITH AS 时去除多余的 SELECT * FROM(...) 包装
1 parent 6ff1996 commit 5f94a63

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3990,7 +3990,8 @@ else if (isPresto() || isTrino()) {
39903990
* @throws Exception
39913991
*/
39923992
private String withAsExpreSubqueryString(SQLConfig cfg, Subquery subquery) throws Exception {
3993-
List<String> list = isWithAsEnable() ? getWithAsExprSqlList() : null;
3993+
boolean isWithAsEnable = isWithAsEnable();
3994+
List<String> list = isWithAsEnable ? getWithAsExprSqlList() : null;
39943995
if (cfg.getMethod() != RequestMethod.POST && list == null) {
39953996
clearWithAsExprListIfNeed();
39963997
}
@@ -4018,7 +4019,7 @@ private String withAsExpreSubqueryString(SQLConfig cfg, Subquery subquery) throw
40184019
} else {
40194020
withAsExpreSql = cfg.getSQL(isPrepared());
40204021
// mysql 才存在这个问题, 主表和子表是一张表
4021-
if (isMySQL() && StringUtil.equals(getTable(), subquery.getFrom())) {
4022+
if (isWithAsEnable && isMySQL() && StringUtil.equals(getTable(), subquery.getFrom())) {
40224023
withAsExpreSql = " SELECT * FROM (" + withAsExpreSql + ") AS " + quote + subquery.getKey() + quote;
40234024
}
40244025
}

0 commit comments

Comments
 (0)