forked from github/dataease
fix: 支持解析多重小括号的sql
This commit is contained in:
parent
a298652d65
commit
0180110e93
@ -101,6 +101,21 @@ public class SqlparserUtils {
|
||||
private static void handleFromItems(PlainSelect plainSelect, String dsType) throws Exception {
|
||||
FromItem fromItem = plainSelect.getFromItem();
|
||||
if (fromItem instanceof ParenthesedSelect) {
|
||||
handleParenthesedSelect(fromItem, dsType);
|
||||
plainSelect.setFromItem(fromItem);
|
||||
} else {
|
||||
if (fromItem instanceof ParenthesedFromItem) {
|
||||
fromItem = ((ParenthesedFromItem) fromItem).getFromItem();
|
||||
while (fromItem instanceof ParenthesedFromItem) {
|
||||
fromItem = ((ParenthesedFromItem) fromItem).getFromItem();
|
||||
}
|
||||
handleParenthesedSelect(fromItem, dsType);
|
||||
}
|
||||
plainSelect.setFromItem(fromItem);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleParenthesedSelect(FromItem fromItem, String dsType) throws Exception {
|
||||
if (((ParenthesedSelect) fromItem).getSelect() instanceof SetOperationList) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
SetOperationList setOperationList = (SetOperationList) ((ParenthesedSelect) fromItem).getSelect().getSelectBody();
|
||||
@ -125,8 +140,6 @@ public class SqlparserUtils {
|
||||
fromItem.setAlias(new Alias(fromItem.getAlias().toString(), false));
|
||||
}
|
||||
}
|
||||
plainSelect.setFromItem(fromItem);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleJoins(PlainSelect plainSelect, String dsType) throws Exception {
|
||||
|
@ -30,6 +30,7 @@ public class FieldUtils {
|
||||
case "DATETIMEOFFSET":
|
||||
case "SMALLDATETIME":
|
||||
case "DATETIME64":
|
||||
case "_TIMESTAMPTZ":
|
||||
return 1;// 时间
|
||||
case "INT":
|
||||
case "SMALLINT":
|
||||
|
Loading…
Reference in New Issue
Block a user