提交 ad68f1ec authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add ExtTypeInfo.getCreateSQL()

上级 74188a32
......@@ -5027,7 +5027,7 @@ public class Parser {
} catch (DbException e) {
throw e.addSQL(original);
}
original += extTypeInfo.toString();
original += extTypeInfo.getCreateSQL();
}
} else if (dataType.type == Value.GEOMETRY) {
if (extTypeInfo == null) {
......@@ -5051,7 +5051,7 @@ public class Parser {
}
read(CLOSE_PAREN);
extTypeInfo = new ExtTypeInfoGeometry(type, srid);
original += extTypeInfo.toString();
original += extTypeInfo.getCreateSQL();
}
}
} else if (readIf(OPEN_PAREN)) {
......
......@@ -515,7 +515,7 @@ public class Column {
}
//$FALL-THROUGH$
case Value.ENUM:
buff.append(extTypeInfo.toString());
buff.append(extTypeInfo.getCreateSQL());
break;
case Value.BYTES:
case Value.STRING:
......
......@@ -19,4 +19,16 @@ public abstract class ExtTypeInfo {
*/
public abstract Value cast(Value value);
/**
* Returns SQL including parentheses that should be appended to a type name.
*
* @return SQL including parentheses that should be appended to a type name
*/
public abstract String getCreateSQL();
@Override
public String toString() {
return getCreateSQL();
}
}
......@@ -43,7 +43,7 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
return label == null ? null : label.trim().toUpperCase(Locale.ENGLISH);
}
private static String toString(String[] enumerators) {
private static String toSQL(String[] enumerators) {
StringBuilder result = new StringBuilder();
result.append('(');
for (int i = 0; i < enumerators.length; i++) {
......@@ -83,7 +83,7 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
}
for (int j = 0; j < i; j++) {
if (l.equals(cleaned[j])) {
throw DbException.get(ErrorCode.ENUM_DUPLICATE, toString(enumerators));
throw DbException.get(ErrorCode.ENUM_DUPLICATE, toSQL(enumerators));
}
}
cleaned[i] = l;
......@@ -177,8 +177,8 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
}
@Override
public String toString() {
return toString(enumerators);
public String getCreateSQL() {
return toSQL(enumerators);
}
}
......@@ -18,7 +18,7 @@ public final class ExtTypeInfoGeometry extends ExtTypeInfo {
private final Integer srid;
private static String toString(int type, Integer srid) {
private static String toSQL(int type, Integer srid) {
if (type == 0 && srid == null) {
return "";
}
......@@ -58,14 +58,14 @@ public final class ExtTypeInfoGeometry extends ExtTypeInfo {
ValueGeometry g = (ValueGeometry) value;
if (type != 0 && g.getTypeAndDimensionSystem() != type || srid != null && g.getSRID() != srid) {
throw DbException.get(ErrorCode.CHECK_CONSTRAINT_VIOLATED_1,
toString(g.getTypeAndDimensionSystem(), g.getSRID()) + " <> " + toString());
toSQL(g.getTypeAndDimensionSystem(), g.getSRID()) + " <> " + toString());
}
return g;
}
@Override
public String toString() {
return toString(type, srid);
public String getCreateSQL() {
return toSQL(type, srid);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论