bug fixed for mysql parser. for issue #2114

This commit is contained in:
wenshao
2018-02-04 14:25:16 +08:00
parent c964fd3ef0
commit ac5edc6b36
3 changed files with 85 additions and 9 deletions
@@ -88,21 +88,41 @@ public final class ExportParameterVisitorUtils {
if (param instanceof SQLCharExpr) {
value = ((SQLCharExpr) param).getText();
replace = true;
}
if (param instanceof SQLBooleanExpr) {
} else if (param instanceof SQLBooleanExpr) {
value = ((SQLBooleanExpr) param).getBooleanValue();
replace = true;
}
if (param instanceof SQLNumericLiteralExpr) {
} else if (param instanceof SQLNumericLiteralExpr) {
value = ((SQLNumericLiteralExpr) param).getNumber();
replace = true;
}
if (param instanceof SQLHexExpr) {
} else if (param instanceof SQLHexExpr) {
value = ((SQLHexExpr) param).toBytes();
replace = true;
} else if (param instanceof SQLListExpr) {
SQLListExpr list = ((SQLListExpr) param);
List<Object> listValues = new ArrayList<Object>();
for (int i = 0; i < list.getItems().size(); i++) {
SQLExpr listItem = list.getItems().get(i);
if (listItem instanceof SQLCharExpr) {
Object listValue = ((SQLCharExpr) listItem).getText();
listValues.add(listValue);
} else if (listItem instanceof SQLBooleanExpr) {
Object listValue = ((SQLBooleanExpr) listItem).getBooleanValue();
listValues.add(listValue);
} else if (listItem instanceof SQLNumericLiteralExpr) {
Object listValue = ((SQLNumericLiteralExpr) listItem).getNumber();
listValues.add(listValue);
} else if (param instanceof SQLHexExpr) {
Object listValue = ((SQLHexExpr) listItem).toBytes();
listValues.add(listValue);
}
}
if (listValues.size() == list.getItems().size()) {
value = listValues;
replace = true;
}
}
if (replace) {
@@ -1204,6 +1204,19 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
boolean allLiteral = true;
for (SQLExpr item : targetList) {
if (!(item instanceof SQLLiteralExpr || item instanceof SQLVariantRefExpr)) {
if (item instanceof SQLListExpr) {
SQLListExpr list = (SQLListExpr) item;
for (SQLExpr listItem : list.getItems()) {
if (!(listItem instanceof SQLLiteralExpr || listItem instanceof SQLVariantRefExpr)) {
allLiteral = false;
break;
}
}
if (allLiteral) {
break;
}
continue;
}
allLiteral = false;
break;
}