@Override protected TableField<Record2<String, NamedToroIndex>, NamedToroIndex> createIndexField(ToroIndexToJsonConverter indexToJsonConverter) { return createField("index", new DefaultDataType<String>(null, String.class, "json") .asConvertedDataType(indexToJsonConverter)); } }
public static final <T> DataType<T> getDataType(SQLDialect dialect, Class<T> type) { return getDataType(dialect, type, null); }
/** * Convert a type name (using precision and scale) into a Java class */ public static DataType<?> getDataType(SQLDialect dialect, String t, int p, int s) throws SQLDialectNotSupportedException { DataType<?> result = DefaultDataType.getDataType(dialect, DefaultDataType.normalise(t)); if (result.getType() == BigDecimal.class) { result = DefaultDataType.getDataType(dialect, getNumericClass(p, s)); } return result; }
@Override public final DataType<T> scale(int s) { if (scale == s) return this; // [#4120] LOB types are not allowed to have scale if (isLob()) return this; else return new DefaultDataType<T>(this, precision, s, length, nullability, collation, identity, defaultValue); }
/** * Convert a type name (using precision and scale) into a Java class */ public static final DataType<?> getDataType(SQLDialect dialect, String t, int p, int s) throws SQLDialectNotSupportedException { DataType<?> result = DefaultDataType.getDataType(dialect, t); if (result.getType() == BigDecimal.class) result = DefaultDataType.getDataType(dialect, getNumericClass(p, s)); return result; }
@Override public final DataType<T> precision(int p, int s) { if (precision == p && scale == s) { return this; } else { return new DefaultDataType<T>(dialect, sqlDataType, type, typeName, castTypeName, p, s, length, nullable, defaulted); } }
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; }
@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 <U> DataType<U> asConvertedDataType(Converter<? super T, U> converter) { return asConvertedDataType(DefaultBinding.newBinding(converter, this, null)); }
this.identity = identity; this.defaultValue = defaultValue; this.precision = precision0(type, precision); this.scale = scale; this.length = length; String normalised = DefaultDataType.normalise(typeName); this.binding = binding != null ? binding : binding(type, isLob()); this.tType = this.binding.converter().fromType();
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof DefaultDataTypeDefinition) { DefaultDataTypeDefinition other = (DefaultDataTypeDefinition) obj; if (!normalise(type).equals(normalise(other.type))) return false; if (userType == null && other.userType == null) return true; if (userType == null || other.userType == null) return false; return normalise(userType.last()).equals(normalise(other.userType.last())); } return false; }
public static void registerDataTypes(DSLContext dsl) { SQLDialect dialect = dsl.dialect(); switch (dialect.family().toString()) { case "MYSQL": case "POSTGRES": case "SQLSERVER": DefaultDataType.getDefaultDataType(SQLDialect.DEFAULT, "geometry"); break; } }
@Override public String toString() { return getCastTypeName() + " (" + type.getName() + ")"; }
@Override public final DataType<T> scale(int s) { if (scale == s) { return this; } else { return new DefaultDataType<T>(dialect, sqlDataType, type, typeName, castTypeName, precision, s, length, nullable, defaulted); } }
@Override public final DataType<T> length(int l) { if (length == l) return this; // [#4120] LOB types are not allowed to have length if (isLob()) return this; else return new DefaultDataType<T>(this, precision, scale, l, nullability, collation, identity, defaultValue); }
@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; }
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; }
/** * Create a new routine call instance */ public ProcessLogNextRange1() { super("process_log_next_range", Public.PUBLIC, org.jooq.impl.DefaultDataType.getDefaultDataType("\"pg_catalog\".\"int4range\"")); setReturnParameter(RETURN_VALUE); addInParameter(PROC_ID); addInParameter(DATA_LEN); setOverloaded(true); }
@Override public String toString() { return getCastTypeName() + " (" + uType.getName() + ")"; }
public static <T> DataType<T> getDataType(SQLDialect dialect, Class<T> type) { return getDataType(dialect, type, null); }