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

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,21 @@ protected String concatJoinOn(@NotNull String sql, @NotNull String quote, @NotNu

String rt = on.getRelateType();
if (StringUtil.isEmpty(rt, false)) {
sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? " != " : " = ")
+ quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote;
// 解决 JOIN ON 不支持 @cast 问题
SQLConfig jc = j.getJoinConfig();
Map<String, String> castMap = jc == null ? null : jc.getCast();
if (castMap == null || castMap.isEmpty()) {
sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? " != " : " = ")
+ quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote;
} else {
String leftTableRelationSql = quote + jt + quote + "." + quote + on.getKey() + quote;
Object castValueType = castMap.get(on.getOriginKey());
if (castValueType != null) {
leftTableRelationSql = "CAST(" + leftTableRelationSql + " AS " + castValueType + ")";
}
sql += (first ? ON : AND) + leftTableRelationSql + (isNot ? " != " : " = ")
+ quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote;
}
}
else {
onJoinComplexRelation(sql, quote, j, jt, onList, on);
Expand Down