Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 324fe32

Browse files
committed
优化 JOIN 中的副表别名,用 __ 双下划线替代原来的 _ 单下划线
1 parent e5261ec commit 324fe32

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ default String getSQLAlias() {
354354
return getSQLAlias(getTable(), getAlias());
355355
}
356356
static String getSQLAlias(@NotNull String table, String alias) {
357-
return StringUtil.isEmpty(alias) ? table : table + "_" + alias; // 带上原表名,避免 alias 和其它表名/字段名冲突
357+
// 这里不用 : $ 等符号,因为部分数据库/引擎似乎不支持 `key`, "key", [key] 等避免关键词冲突的方式,只能使用符合变量命名的表别名
358+
return StringUtil.isEmpty(alias) ? table : table + "__" + alias; // 带上原表名,避免 alias 和其它表名/字段名冲突
358359
}
359360

360361

0 commit comments

Comments
 (0)