public static DataType<?> getDataType(SQLDialect dialect, String typeName) { String normalised = DefaultDataType.normalise(typeName); DataType<?> result = TYPES_BY_NAME[dialect.ordinal()].get(normalised); // UDT data types and others are registered using SQL99 if (result == null) { result = TYPES_BY_NAME[SQLDialect.SQL99.ordinal()].get(normalised); } if (result == null) { // [#366] Don't log a warning here. The warning is logged when // catching the exception in jOOQ-codegen throw new SQLDialectNotSupportedException("Type " + typeName + " is not supported in dialect " + dialect, false); } return result; }
public static final DataType<?> getDataType(SQLDialect dialect, String typeName) { SQLDialect family = dialect.family(); int ordinal = family.ordinal(); String upper = typeName.toUpperCase(); String normalised = typeName; DataType<?> result = TYPES_BY_NAME[ordinal].get(upper); // [#3225] Normalise only if necessary if (result == null) { result = TYPES_BY_NAME[ordinal].get(normalised = DefaultDataType.normalise(typeName)); // UDT data types and others are registered using DEFAULT if (result == null) { result = TYPES_BY_NAME[SQLDialect.DEFAULT.ordinal()].get(normalised); // [#4065] PostgreSQL reports array types as _typename, e.g. _varchar if (result == null && ( family == POSTGRES) && normalised.charAt(0) == '_') result = getDataType(dialect, normalised.substring(1)).getArrayDataType(); // [#6466] HSQLDB reports array types as XYZARRAY if (result == null && family == HSQLDB && upper.endsWith(" ARRAY")) result = getDataType(dialect, typeName.substring(0, typeName.length() - 6)).getArrayDataType(); // [#366] Don't log a warning here. The warning is logged when // catching the exception in jOOQ-codegen if (result == null) throw new SQLDialectNotSupportedException("Type " + typeName + " is not supported in dialect " + dialect, false); } } return result; }
result = TYPES_BY_TYPE[dialect.family().ordinal()].get(type);
@Override public final DataType<T> getDataType(Configuration configuration) { // If this is a SQLDataType find the most suited dialect-specific // data type if (getDialect() == null) { DataType<?> dataType = TYPES_BY_SQL_DATATYPE[configuration.dialect().family().ordinal()] // Be sure to reset length, precision, and scale, as those values // were not registered in the below cache .get(length(0).precision(0, 0)); if (dataType != null) { // ... and then, set them back to the original value // [#2710] TODO: Remove this logic along with cached data types return (DataType<T>) dataType.length(length).precision(precision, scale); } } // If this is already the dialect's specific data type, return this else if (getDialect().family() == configuration.dialect().family()) { return this; } // If the SQL data type is not available stick with this data type else if (getSQLDataType() == null) { return this; } // If this is another dialect's specific data type, recurse else { getSQLDataType().getDataType(configuration); } return this; }
@Override public final DataType<T> getDataType(Configuration configuration) { // If this is a SQLDataType find the most suited dialect-specific // data type if (getDialect() == null) { DataType<?> dataType = TYPES_BY_SQL_DATATYPE[configuration.dialect().family().ordinal()] // Be sure to reset length, precision, and scale, as those values // were not registered in the below cache .get(length(0).precision(0, 0)); if (dataType != null) { // ... and then, set them back to the original value // [#2710] TODO: Remove this logic along with cached data types return (DataType<T>) dataType.length(length).precision(precision, scale); } } // If this is already the dialect's specific data type, return this else if (getDialect().family() == configuration.dialect().family()) { return this; } // If the SQL data type is not available stick with this data type else if (getSQLDataType() == null) { return this; } // If this is another dialect's specific data type, recurse else { getSQLDataType().getDataType(configuration); } return this; }