提交 9cc7cb9a authored 作者: Max Englander's avatar Max Englander

enum-support: fix bug where enumerators incorrectly assigned to column

上级 62e880b1
......@@ -4122,7 +4122,7 @@ public class Parser {
}
long precision = -1;
int displaySize = -1;
java.util.List<String> enumerators = new ArrayList<String>();
java.util.List<String> enumerators = null;
int scale = -1;
String comment = null;
Column templateColumn = null;
......@@ -4198,6 +4198,7 @@ public class Parser {
}
} else if (dataType.enumerated) {
if (readIf("(")) {
enumerators = new ArrayList<String>();
original += '(';
String enumerator0 = readString();
enumerators.add(enumerator0.toLowerCase().trim());
......@@ -4232,7 +4233,7 @@ public class Parser {
Integer.toString(scale), Long.toString(precision));
}
Column column = new Column(columnName, type, precision, scale,
displaySize, enumerators.toArray(new String[enumerators.size()]));
displaySize, enumerators == null ? null : enumerators.toArray(new String[enumerators.size()]));
if (templateColumn != null) {
column.setNullable(templateColumn.isNullable());
column.setDefaultExpression(session,
......
......@@ -80,7 +80,7 @@ public class ValueEnum extends Value {
return;
default:
throw DbException.get(ErrorCode.VALUE_NOT_PERMITTED,
"Provided value does not match any enumerators", value.toString());
"Provided value does not match any enumerators " + toString(enumerators), value.toString());
}
}
......@@ -194,6 +194,18 @@ public class ValueEnum extends Value {
prep.setInt(parameterIndex, ordinal);
}
private static String toString(final String[] enumerators) {
String result = "(";
for (int i = 0; i < enumerators.length; i++) {
result += "'" + enumerators[i] + "'";
if (i < enumerators.length - 1) {
result += ", ";
}
}
result += ")";
return result;
}
private static Validation validate(final String[] enumerators, final String label) {
check(enumerators);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论