fix(数据集): 创建join语句参数化无法保存

This commit is contained in:
taojinlong 2023-01-09 16:33:52 +08:00
parent ef9db3c5c6
commit c1bd98eccb

View File

@ -1119,12 +1119,13 @@ public class DataSetTableService {
if (fromItem.getAlias() == null) { if (fromItem.getAlias() == null) {
throw new Exception("Failed to parse sql, Every derived table must have its own alias"); throw new Exception("Failed to parse sql, Every derived table must have its own alias");
} }
subSelect.setAlias(new Alias(fromItem.getAlias().toString())); subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false));
} }
plainSelect.setFromItem(subSelect); plainSelect.setFromItem(subSelect);
} }
List<Join> joins = plainSelect.getJoins(); List<Join> joins = plainSelect.getJoins();
if (joins != null) { if (joins != null) {
List<Join> joinsList = new ArrayList<>();
for (Join join : joins) { for (Join join : joins) {
FromItem rightItem = join.getRightItem(); FromItem rightItem = join.getRightItem();
if (rightItem instanceof SubSelect) { if (rightItem instanceof SubSelect) {
@ -1139,14 +1140,13 @@ public class DataSetTableService {
if (rightItem.getAlias() == null) { if (rightItem.getAlias() == null) {
throw new Exception("Failed to parse sql, Every derived table must have its own alias"); throw new Exception("Failed to parse sql, Every derived table must have its own alias");
} }
subSelect.setAlias(new Alias(rightItem.getAlias().toString())); subSelect.setAlias(new Alias(rightItem.getAlias().toString(), false));
} }
List<Join> joinsList = new ArrayList<>();
join.setRightItem(subSelect); join.setRightItem(subSelect);
joinsList.add(join); joinsList.add(join);
plainSelect.setJoins(joinsList);
} }
} }
plainSelect.setJoins(joinsList);
} }
Expression expr = plainSelect.getWhere(); Expression expr = plainSelect.getWhere();
if (expr == null) { if (expr == null) {