提交 68ec6cf3 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove DataType.defaultDisplaySize and fix display size in TypeInfo

上级 23492d1a
......@@ -5899,7 +5899,7 @@ public class Parser {
String columnName = "C" + (i + 1);
if (rows.isEmpty()) {
if (type.getValueType() == Value.UNKNOWN) {
type = TypeInfo.TYPE_STRING_DEFAULT;
type = TypeInfo.TYPE_STRING;
}
column = new Column(columnName, type);
columns.add(column);
......
......@@ -172,7 +172,7 @@ public class BinaryOperation extends Expression {
break;
}
}
type = TypeInfo.TYPE_STRING_DEFAULT;
type = TypeInfo.TYPE_STRING;
break;
}
case PLUS:
......@@ -188,7 +188,7 @@ public class BinaryOperation extends Expression {
// string when text concatenation with + is enabled
if (opType == OpType.PLUS && session.getDatabase().
getMode().allowPlusForStringConcat) {
type = TypeInfo.TYPE_STRING_DEFAULT;
type = TypeInfo.TYPE_STRING;
opType = OpType.CONCAT;
} else {
type = TypeInfo.TYPE_DECIMAL_DEFAULT;
......
......@@ -648,7 +648,7 @@ public class Aggregate extends AbstractAggregate {
}
switch (aggregateType) {
case GROUP_CONCAT:
type = TypeInfo.TYPE_STRING_DEFAULT;
type = TypeInfo.TYPE_STRING;
break;
case COUNT_ALL:
case COUNT:
......
......@@ -2374,7 +2374,7 @@ public class Function extends Expression implements FunctionCall {
}
}
if (typeInfo.getValueType() == Value.UNKNOWN) {
typeInfo = TypeInfo.TYPE_STRING_DEFAULT;
typeInfo = TypeInfo.TYPE_STRING;
}
break;
}
......@@ -2406,7 +2406,7 @@ public class Function extends Expression implements FunctionCall {
}
}
if (typeInfo.getValueType() == Value.UNKNOWN) {
typeInfo = TypeInfo.TYPE_STRING_DEFAULT;
typeInfo = TypeInfo.TYPE_STRING;
}
break;
}
......
......@@ -3187,12 +3187,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements
public ResultSet getClientInfoProperties() throws SQLException {
Properties clientInfo = conn.getClientInfo();
SimpleResult result = new SimpleResult();
result.addColumn("NAME", "NAME", TypeInfo.TYPE_STRING_DEFAULT);
result.addColumn("NAME", "NAME", TypeInfo.TYPE_STRING);
result.addColumn("MAX_LEN", "MAX_LEN", TypeInfo.TYPE_INT);
result.addColumn("DEFAULT_VALUE", "DEFAULT_VALUE", TypeInfo.TYPE_STRING_DEFAULT);
result.addColumn("DESCRIPTION", "DESCRIPTION", TypeInfo.TYPE_STRING_DEFAULT);
result.addColumn("DEFAULT_VALUE", "DEFAULT_VALUE", TypeInfo.TYPE_STRING);
result.addColumn("DESCRIPTION", "DESCRIPTION", TypeInfo.TYPE_STRING);
// Non-standard column
result.addColumn("VALUE", "VALUE", TypeInfo.TYPE_STRING_DEFAULT);
result.addColumn("VALUE", "VALUE", TypeInfo.TYPE_STRING);
for (Entry<Object, Object> entry : clientInfo.entrySet()) {
result.addRow(ValueString.get((String) entry.getKey()), ValueInt.get(Integer.MAX_VALUE),
ValueString.EMPTY, ValueString.EMPTY, ValueString.get((String) entry.getValue()));
......
......@@ -158,11 +158,6 @@ public class DataType {
*/
public int defaultScale;
/**
* The default display size.
*/
public int defaultDisplaySize;
/**
* If this data type should not be listed in the database meta data.
*/
......@@ -185,7 +180,6 @@ public class DataType {
DataType dataType = new DataType();
dataType.defaultPrecision = dataType.maxPrecision = ValueNull.PRECISION;
dataType.defaultDisplaySize = ValueNull.DISPLAY_SIZE;
add(Value.NULL, Types.NULL,
dataType,
new String[]{"NULL"},
......@@ -337,7 +331,6 @@ public class DataType {
dataType = new DataType();
dataType.prefix = dataType.suffix = "'";
dataType.defaultPrecision = dataType.maxPrecision = ValueUuid.PRECISION;
dataType.defaultDisplaySize = ValueUuid.DISPLAY_SIZE;
add(Value.UUID, Types.BINARY,
createString(false),
// UNIQUEIDENTIFIER is the MSSQL mode equivalent
......@@ -377,7 +370,7 @@ public class DataType {
32
);
dataType = new DataType();
dataType.maxPrecision = dataType.defaultPrecision = dataType.defaultDisplaySize = Integer.MAX_VALUE;
dataType.maxPrecision = dataType.defaultPrecision = Integer.MAX_VALUE;
add(Value.RESULT_SET, DataType.TYPE_RESULT_SET,
dataType,
new String[]{"RESULT_SET"},
......@@ -441,9 +434,6 @@ public class DataType {
dataType.defaultScale = ValueInterval.DEFAULT_SCALE;
dataType.maxScale = ValueInterval.MAXIMUM_SCALE;
}
dataType.defaultDisplaySize = ValueInterval.getDisplaySize(type, ValueInterval.DEFAULT_PRECISION,
// Scale will be ignored if it is not supported
ValueInterval.DEFAULT_SCALE);
add(type, Types.OTHER, dataType,
new String[]{("INTERVAL " + name).intern()},
36
......@@ -469,7 +459,6 @@ public class DataType {
dt.supportsScale = dataType.supportsScale;
dt.defaultPrecision = dataType.defaultPrecision;
dt.defaultScale = dataType.defaultScale;
dt.defaultDisplaySize = dataType.defaultDisplaySize;
dt.caseSensitive = dataType.caseSensitive;
dt.hidden = i > 0;
dt.memory = memory;
......@@ -504,7 +493,6 @@ public class DataType {
dataType.maxPrecision = maxPrecision;
dataType.defaultPrecision = defaultPrecision;
dataType.defaultScale = defaultScale;
dataType.defaultDisplaySize = defaultDisplaySize;
if (needsPrecisionAndScale) {
dataType.params = "PRECISION,SCALE";
dataType.supportsPrecision = true;
......@@ -537,7 +525,6 @@ public class DataType {
dataType.maxScale = maxScale;
dataType.defaultPrecision = precision;
dataType.defaultScale = scale;
dataType.defaultDisplaySize = precision;
return dataType;
}
......@@ -550,7 +537,6 @@ public class DataType {
dataType.supportsPrecision = true;
dataType.maxPrecision = Integer.MAX_VALUE;
dataType.defaultPrecision = Integer.MAX_VALUE;
dataType.defaultDisplaySize = Integer.MAX_VALUE;
return dataType;
}
......@@ -568,7 +554,6 @@ public class DataType {
dataType.params = "TYPE,SRID";
dataType.maxPrecision = Integer.MAX_VALUE;
dataType.defaultPrecision = Integer.MAX_VALUE;
dataType.defaultDisplaySize = Integer.MAX_VALUE;
return dataType;
}
......
......@@ -7,6 +7,7 @@ package org.h2.value;
import org.h2.api.CustomDataTypesHandler;
import org.h2.api.ErrorCode;
import org.h2.api.IntervalQualifier;
import org.h2.message.DbException;
import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils;
......@@ -51,6 +52,11 @@ public class TypeInfo {
*/
public static final TypeInfo TYPE_LONG;
/**
* DECIMAL type with maximum parameters.
*/
public static final TypeInfo TYPE_DECIMAL;
/**
* DECIMAL type with default parameters.
*/
......@@ -67,7 +73,7 @@ public class TypeInfo {
public static final TypeInfo TYPE_FLOAT;
/**
* TIME type with parameters.
* TIME type with maximum parameters.
*/
public static final TypeInfo TYPE_TIME;
......@@ -77,14 +83,14 @@ public class TypeInfo {
public static final TypeInfo TYPE_DATE;
/**
* TIMESTAMP type with parameters.
* TIMESTAMP type with maximum parameters.
*/
public static final TypeInfo TYPE_TIMESTAMP;
/**
* STRING type with default parameters.
* STRING type with maximum parameters.
*/
public static final TypeInfo TYPE_STRING_DEFAULT;
public static final TypeInfo TYPE_STRING;
/**
* ARRAY type with parameters.
......@@ -112,7 +118,7 @@ public class TypeInfo {
public static final TypeInfo TYPE_GEOMETRY;
/**
* TIMESTAMP WITH TIME ZONE type with parameters.
* TIMESTAMP WITH TIME ZONE type with maximum parameters.
*/
public static final TypeInfo TYPE_TIMESTAMP_TZ;
......@@ -122,17 +128,17 @@ public class TypeInfo {
public static final TypeInfo TYPE_ENUM_UNDEFINED;
/**
* INTERVAL DAY type with parameters.
* INTERVAL DAY type with maximum parameters.
*/
public static final TypeInfo TYPE_INTERVAL_DAY;
/**
* INTERVAL DAY TO SECOND type with parameters.
* INTERVAL DAY TO SECOND type with maximum parameters.
*/
public static final TypeInfo TYPE_INTERVAL_DAY_TO_SECOND;
/**
* INTERVAL HOUR TO SECOND type with parameters.
* INTERVAL HOUR TO SECOND type with maximum parameters.
*/
public static final TypeInfo TYPE_INTERVAL_HOUR_TO_SECOND;
......@@ -154,40 +160,61 @@ public class TypeInfo {
private final ExtTypeInfo extTypeInfo;
static {
DataType[] type = DataType.TYPES_BY_VALUE_TYPE;
TypeInfo[] infos = new TypeInfo[Value.TYPE_COUNT];
for (int i = 0; i < type.length; i++) {
DataType dt = type[i];
if (dt != null) {
Value.getOrder(i);
infos[i] = createTypeInfo(i, dt);
}
}
TYPE_UNKNOWN = new TypeInfo(Value.UNKNOWN, -1L, -1, -1, null);
TYPE_NULL = infos[Value.NULL];
TYPE_BOOLEAN = infos[Value.BOOLEAN];
TYPE_BYTE = infos[Value.BYTE];
TYPE_SHORT = infos[Value.SHORT];
TYPE_INT = infos[Value.INT];
TYPE_LONG = infos[Value.LONG];
TYPE_DECIMAL_DEFAULT = infos[Value.DECIMAL];
TYPE_DOUBLE = infos[Value.DOUBLE];
TYPE_FLOAT = infos[Value.FLOAT];
TYPE_TIME = infos[Value.TIME];
TYPE_DATE = infos[Value.DATE];
TYPE_TIMESTAMP = infos[Value.TIMESTAMP];
TYPE_STRING_DEFAULT = infos[Value.STRING];
TYPE_ARRAY = infos[Value.ARRAY];
TYPE_RESULT_SET = infos[Value.RESULT_SET];
TYPE_JAVA_OBJECT = infos[Value.JAVA_OBJECT];
TYPE_UUID = infos[Value.UUID];
TYPE_GEOMETRY = infos[Value.GEOMETRY];
TYPE_TIMESTAMP_TZ = infos[Value.TIMESTAMP_TZ];
TYPE_ENUM_UNDEFINED = infos[Value.ENUM];
infos[Value.NULL] = TYPE_NULL = new TypeInfo(Value.NULL, ValueNull.PRECISION, 0, ValueNull.DISPLAY_SIZE, null);
infos[Value.BOOLEAN] = TYPE_BOOLEAN = new TypeInfo(Value.BOOLEAN, ValueBoolean.PRECISION, 0,
ValueBoolean.DISPLAY_SIZE, null);
infos[Value.BYTE] = TYPE_BYTE = new TypeInfo(Value.BYTE, ValueByte.PRECISION, 0, ValueByte.DISPLAY_SIZE, null);
infos[Value.SHORT] = TYPE_SHORT = new TypeInfo(Value.SHORT, ValueShort.PRECISION, 0, ValueShort.DISPLAY_SIZE,
null);
infos[Value.INT] = TYPE_INT = new TypeInfo(Value.INT, ValueInt.PRECISION, 0, ValueInt.DISPLAY_SIZE, null);
infos[Value.LONG] = TYPE_LONG = new TypeInfo(Value.LONG, ValueLong.PRECISION, 0, ValueLong.DISPLAY_SIZE, null);
infos[Value.DECIMAL] = TYPE_DECIMAL= new TypeInfo(Value.DECIMAL, Integer.MAX_VALUE, Integer.MAX_VALUE,
Integer.MAX_VALUE, null);
TYPE_DECIMAL_DEFAULT = new TypeInfo(Value.DECIMAL, ValueDecimal.DEFAULT_PRECISION, ValueDecimal.DEFAULT_SCALE,
ValueDecimal.DEFAULT_PRECISION + 2, null);
infos[Value.DOUBLE] = TYPE_DOUBLE = new TypeInfo(Value.DOUBLE, ValueDouble.PRECISION, 0,
ValueDouble.DISPLAY_SIZE, null);
infos[Value.FLOAT] = TYPE_FLOAT = new TypeInfo(Value.FLOAT, ValueFloat.PRECISION, 0, ValueFloat.DISPLAY_SIZE,
null);
infos[Value.TIME] = TYPE_TIME = new TypeInfo(Value.TIME, ValueTime.MAXIMUM_PRECISION, ValueTime.MAXIMUM_SCALE,
ValueTime.MAXIMUM_PRECISION, null);
infos[Value.DATE] = TYPE_DATE = new TypeInfo(Value.DATE, ValueDate.PRECISION, 0, ValueDate.PRECISION, null);
infos[Value.TIMESTAMP] = TYPE_TIMESTAMP = new TypeInfo(Value.TIMESTAMP, ValueTimestamp.MAXIMUM_PRECISION,
ValueTimestamp.MAXIMUM_SCALE, ValueTimestamp.MAXIMUM_PRECISION, null);
infos[Value.BYTES] = new TypeInfo(Value.BYTES, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
infos[Value.STRING] = TYPE_STRING = new TypeInfo(Value.STRING, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
infos[Value.STRING_IGNORECASE] = new TypeInfo(Value.STRING_IGNORECASE, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
null);
infos[Value.BLOB] = new TypeInfo(Value.BLOB, Long.MAX_VALUE, 0, Integer.MAX_VALUE, null);
infos[Value.CLOB] = new TypeInfo(Value.CLOB, Long.MAX_VALUE, 0, Integer.MAX_VALUE, null);
infos[Value.ARRAY] = TYPE_ARRAY = new TypeInfo(Value.ARRAY, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
infos[Value.RESULT_SET] = TYPE_RESULT_SET = new TypeInfo(Value.RESULT_SET, Integer.MAX_VALUE,
Integer.MAX_VALUE, Integer.MAX_VALUE, null);
infos[Value.JAVA_OBJECT] = TYPE_JAVA_OBJECT = new TypeInfo(Value.JAVA_OBJECT, Integer.MAX_VALUE, 0,
Integer.MAX_VALUE, null);
infos[Value.UUID] = TYPE_UUID = new TypeInfo(Value.UUID, ValueUuid.PRECISION, 0, ValueUuid.DISPLAY_SIZE, null);
infos[Value.STRING_FIXED] = new TypeInfo(Value.STRING_FIXED, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
null);
infos[Value.GEOMETRY] = TYPE_GEOMETRY = new TypeInfo(Value.GEOMETRY, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
null);
infos[Value.TIMESTAMP_TZ] = TYPE_TIMESTAMP_TZ = new TypeInfo(Value.TIMESTAMP_TZ,
ValueTimestampTimeZone.MAXIMUM_PRECISION, ValueTimestampTimeZone.MAXIMUM_SCALE,
ValueTimestampTimeZone.MAXIMUM_PRECISION, null);
infos[Value.ENUM] = TYPE_ENUM_UNDEFINED = new TypeInfo(Value.ENUM, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
null);
for (int i = Value.INTERVAL_YEAR; i <= Value.INTERVAL_MINUTE_TO_SECOND; i++) {
infos[i] = new TypeInfo(i, ValueInterval.MAXIMUM_PRECISION,
IntervalQualifier.valueOf(i - Value.INTERVAL_YEAR).hasSeconds() ? ValueInterval.MAXIMUM_SCALE : 0,
ValueInterval.getDisplaySize(i, ValueInterval.MAXIMUM_PRECISION,
// Scale will be ignored if it is not supported
ValueInterval.MAXIMUM_SCALE), null);
}
TYPE_INTERVAL_DAY = infos[Value.INTERVAL_DAY];
TYPE_INTERVAL_DAY_TO_SECOND = infos[Value.INTERVAL_DAY_TO_SECOND];
TYPE_INTERVAL_HOUR_TO_SECOND = infos[Value.INTERVAL_HOUR_TO_SECOND];
TYPE_ROW = infos[Value.ROW];
infos[Value.ROW] = TYPE_ROW = new TypeInfo(Value.ROW, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
TYPE_INFOS_BY_VALUE_TYPE = infos;
}
......@@ -291,7 +318,7 @@ public class TypeInfo {
return new TypeInfo(Value.BYTES, precision, 0, MathUtils.convertLongToInt(precision) * 2, null);
case Value.STRING:
if (precision < 0) {
return TYPE_STRING_DEFAULT;
return TYPE_STRING;
}
//$FALL-THROUGH$
case Value.STRING_FIXED:
......@@ -327,7 +354,7 @@ public class TypeInfo {
case Value.INTERVAL_DAY_TO_HOUR:
case Value.INTERVAL_DAY_TO_MINUTE:
case Value.INTERVAL_HOUR_TO_MINUTE:
if (precision < 0 || precision > ValueInterval.MAXIMUM_PRECISION) {
if (precision < 1 || precision > ValueInterval.MAXIMUM_PRECISION) {
precision = ValueInterval.MAXIMUM_PRECISION;
}
return new TypeInfo(type, precision, 0, ValueInterval.getDisplaySize(type, (int) precision, 0), null);
......@@ -335,7 +362,7 @@ public class TypeInfo {
case Value.INTERVAL_DAY_TO_SECOND:
case Value.INTERVAL_HOUR_TO_SECOND:
case Value.INTERVAL_MINUTE_TO_SECOND:
if (precision < 0 || precision > ValueInterval.MAXIMUM_PRECISION) {
if (precision < 1 || precision > ValueInterval.MAXIMUM_PRECISION) {
precision = ValueInterval.MAXIMUM_PRECISION;
}
if (scale < 0 || scale > ValueInterval.MAXIMUM_SCALE) {
......@@ -353,10 +380,6 @@ public class TypeInfo {
return TYPE_NULL;
}
private static TypeInfo createTypeInfo(int valueType, DataType dataType) {
return new TypeInfo(valueType, dataType.maxPrecision, dataType.maxScale, dataType.defaultDisplaySize, null);
}
/**
* Creates new instance of data type with parameters.
*
......
......@@ -45,6 +45,7 @@ import org.h2.value.ValueDecimal;
import org.h2.value.ValueDouble;
import org.h2.value.ValueFloat;
import org.h2.value.ValueInt;
import org.h2.value.ValueInterval;
import org.h2.value.ValueJavaObject;
import org.h2.value.ValueLobDb;
import org.h2.value.ValueNull;
......@@ -83,6 +84,7 @@ public class TestValue extends TestDb {
testModulusDecimal();
testModulusOperator();
testLobComparison();
testTypeInfo();
}
private void testResultSetOperations() throws SQLException {
......@@ -502,4 +504,118 @@ public class TestValue extends TestDb {
}
}
private void testTypeInfo() {
testTypeInfoCheck(Value.UNKNOWN, -1, -1, -1, TypeInfo.TYPE_UNKNOWN);
try {
TypeInfo.getTypeInfo(Value.UNKNOWN);
fail();
} catch (DbException ex) {
assertEquals(ErrorCode.UNKNOWN_DATA_TYPE_1, ex.getErrorCode());
}
testTypeInfoCheck(Value.NULL, 1, 0, 4, TypeInfo.TYPE_NULL, TypeInfo.getTypeInfo(Value.NULL));
testTypeInfoCheck(Value.BOOLEAN, 1, 0, 5, TypeInfo.TYPE_BOOLEAN, TypeInfo.getTypeInfo(Value.BOOLEAN));
testTypeInfoCheck(Value.BYTE, 3, 0, 4, TypeInfo.TYPE_BYTE, TypeInfo.getTypeInfo(Value.BYTE));
testTypeInfoCheck(Value.SHORT, 5, 0, 6, TypeInfo.TYPE_SHORT, TypeInfo.getTypeInfo(Value.SHORT));
testTypeInfoCheck(Value.INT, 10, 0, 11, TypeInfo.TYPE_INT, TypeInfo.getTypeInfo(Value.INT));
testTypeInfoCheck(Value.LONG, 19, 0, 20, TypeInfo.TYPE_LONG, TypeInfo.getTypeInfo(Value.LONG));
testTypeInfoCheck(Value.FLOAT, 7, 0, 15, TypeInfo.TYPE_FLOAT, TypeInfo.getTypeInfo(Value.FLOAT));
testTypeInfoCheck(Value.DOUBLE, 17, 0, 24, TypeInfo.TYPE_DOUBLE, TypeInfo.getTypeInfo(Value.DOUBLE));
testTypeInfoCheck(Value.DECIMAL, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
TypeInfo.TYPE_DECIMAL, TypeInfo.getTypeInfo(Value.DECIMAL));
testTypeInfoCheck(Value.DECIMAL, 65_535, 32_767, 65_537, TypeInfo.TYPE_DECIMAL_DEFAULT);
testTypeInfoCheck(Value.TIME, 18, 9, 18, TypeInfo.TYPE_TIME, TypeInfo.getTypeInfo(Value.TIME));
for (int s = 0; s <= 9; s++) {
int d = s > 0 ? s + 9 : 8;
testTypeInfoCheck(Value.TIME, d, s, d, TypeInfo.getTypeInfo(Value.TIME, 0, s, null));
}
testTypeInfoCheck(Value.DATE, 10, 0, 10, TypeInfo.TYPE_DATE, TypeInfo.getTypeInfo(Value.DATE));
testTypeInfoCheck(Value.TIMESTAMP, 29, 9, 29, TypeInfo.TYPE_TIMESTAMP, TypeInfo.getTypeInfo(Value.TIMESTAMP));
for (int s = 0; s <= 9; s++) {
int d = s > 0 ? s + 20 : 19;
testTypeInfoCheck(Value.TIMESTAMP, d, s, d, TypeInfo.getTypeInfo(Value.TIMESTAMP, 0, s, null));
}
testTypeInfoCheck(Value.TIMESTAMP_TZ, 35, 9, 35, TypeInfo.TYPE_TIMESTAMP_TZ,
TypeInfo.getTypeInfo(Value.TIMESTAMP_TZ));
for (int s = 0; s <= 9; s++) {
int d = s > 0 ? s + 26 : 25;
testTypeInfoCheck(Value.TIMESTAMP_TZ, d, s, d, TypeInfo.getTypeInfo(Value.TIMESTAMP_TZ, 0, s, null));
}
testTypeInfoCheck(Value.BYTES, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.getTypeInfo(Value.BYTES));
testTypeInfoCheck(Value.BLOB, Long.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.getTypeInfo(Value.BLOB));
testTypeInfoCheck(Value.CLOB, Long.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.getTypeInfo(Value.CLOB));
testTypeInfoCheck(Value.STRING, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.TYPE_STRING,
TypeInfo.getTypeInfo(Value.STRING));
testTypeInfoCheck(Value.STRING_FIXED, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
TypeInfo.getTypeInfo(Value.STRING_FIXED));
testTypeInfoCheck(Value.STRING_IGNORECASE, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
TypeInfo.getTypeInfo(Value.STRING_IGNORECASE));
testTypeInfoCheck(Value.ARRAY, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.TYPE_ARRAY,
TypeInfo.getTypeInfo(Value.ARRAY));
testTypeInfoCheck(Value.RESULT_SET, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
TypeInfo.TYPE_RESULT_SET, TypeInfo.getTypeInfo(Value.RESULT_SET));
testTypeInfoCheck(Value.ROW, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.TYPE_ROW,
TypeInfo.getTypeInfo(Value.ROW));
testTypeInfoCheck(Value.JAVA_OBJECT, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.TYPE_JAVA_OBJECT,
TypeInfo.getTypeInfo(Value.JAVA_OBJECT));
testTypeInfoCheck(Value.UUID, 16, 0, 36, TypeInfo.TYPE_UUID, TypeInfo.getTypeInfo(Value.UUID));
testTypeInfoCheck(Value.GEOMETRY, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.TYPE_GEOMETRY,
TypeInfo.getTypeInfo(Value.GEOMETRY));
testTypeInfoCheck(Value.ENUM, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, TypeInfo.TYPE_ENUM_UNDEFINED,
TypeInfo.getTypeInfo(Value.ENUM));
testTypeInfoInterval1(Value.INTERVAL_YEAR);
testTypeInfoInterval1(Value.INTERVAL_MONTH);
testTypeInfoInterval1(Value.INTERVAL_DAY);
testTypeInfoInterval1(Value.INTERVAL_HOUR);
testTypeInfoInterval1(Value.INTERVAL_MINUTE);
testTypeInfoInterval2(Value.INTERVAL_SECOND);
testTypeInfoInterval1(Value.INTERVAL_YEAR_TO_MONTH);
testTypeInfoInterval1(Value.INTERVAL_DAY_TO_HOUR);
testTypeInfoInterval1(Value.INTERVAL_DAY_TO_MINUTE);
testTypeInfoInterval2(Value.INTERVAL_DAY_TO_SECOND);
testTypeInfoInterval1(Value.INTERVAL_HOUR_TO_MINUTE);
testTypeInfoInterval2(Value.INTERVAL_HOUR_TO_SECOND);
testTypeInfoInterval2(Value.INTERVAL_MINUTE_TO_SECOND);
}
private void testTypeInfoInterval1(int type) {
testTypeInfoCheck(type, 18, 0, ValueInterval.getDisplaySize(type, 18, 0), TypeInfo.getTypeInfo(type));
for (int p = 1; p <= 18; p++) {
testTypeInfoCheck(type, p, 0, ValueInterval.getDisplaySize(type, p, 0),
TypeInfo.getTypeInfo(type, p, 0, null));
}
}
private void testTypeInfoInterval2(int type) {
testTypeInfoCheck(type, 18, 9, ValueInterval.getDisplaySize(type, 18, 9), TypeInfo.getTypeInfo(type));
for (int p = 1; p <= 18; p++) {
for (int s = 0; s <= 9; s++) {
testTypeInfoCheck(type, p, s, ValueInterval.getDisplaySize(type, p, s),
TypeInfo.getTypeInfo(type, p, s, null));
}
}
}
private void testTypeInfoCheck(int valueType, long precision, int scale, int displaySize, TypeInfo... typeInfos) {
for (TypeInfo typeInfo : typeInfos) {
testTypeInfoCheck(valueType, precision, scale, displaySize, typeInfo);
}
}
private void testTypeInfoCheck(int valueType, long precision, int scale, int displaySize, TypeInfo typeInfo) {
assertEquals(valueType, typeInfo.getValueType());
assertEquals(precision, typeInfo.getPrecision());
assertEquals(scale, typeInfo.getScale());
assertEquals(displaySize, typeInfo.getDisplaySize());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论